Re: NSCalenderDate (Patel, Nilesh M)
Re: NSCalenderDate (Patel, Nilesh M)
- Subject: Re: NSCalenderDate (Patel, Nilesh M)
- From: Lorenzo <email@hidden>
- Date: Wed, 26 May 2004 00:33:28 +0200
Yes, you should put the code between the {}
I wrote it here for you. Please note, if you want to know more about a given
class or a given command, write the class on your code page (e.g. write
"NSTextView" or "replaceCharactersInRange") then double click on the class
name holding down the ALT key. You will be taken to the Help page describing
that class or that command. This way you will be able to learn everything
about that class methods. :-)
-(IBAction)dataStamp:(id)sender
{
NSCalendarDate *nowDateTime = [NSCalendarDate calendarDate];
NSString *dateFormat = @"%A, %B %d, %Y - %H:%M:%S";
NSString *timeString;
timeString = [nowDateTime descriptionWithCalendarFormat:dateFormat];
//if you want to print the timeString within
// a NSTextField named myTextField, use the following
[myTextField setObjectValue:timeString];
// instead if you want to paste the timeString
// to a NSTextView named myTextView, write
NSRange selRange = [myTextView selectedRange];
[myTextView replaceCharactersInRange:selRange withString:timeString];
// You will see a string like
// Wednesday, May 26, 2004 - 00:25:36
// don't use both the above methods together
}
Enjoy!
Best Regards
--
Lorenzo
email: email@hidden
>
From: "Patel, Nilesh M" <email@hidden>
>
Date: Tue, 25 May 2004 15:35:38 -0400
>
To: Lorenzo <email@hidden>
>
Subject: RE: NSCalenderDate (Patel, Nilesh M)
>
>
I created a -(IBAction)dataStamp:(id)sender {calender code here?}
>
>
how do I set the date up so I can have it in my action button???
>
-thanks
>
>
-----Original Message-----
>
From: Lorenzo [mailto:email@hidden]
>
Sent: Tuesday, May 25, 2004 11:59 AM
>
To: email@hidden
>
Cc: Patel, Nilesh M
>
Subject: Re: NSCalenderDate (Patel, Nilesh M)
>
>
>
Hi,
>
you should get the current date/time this way:
>
NSCalendarDate *nowDateTime = [NSCalendarDate calendarDate];
>
>
then you can transform "nowDateTime" to a simple NSString this way:
>
NSString *fullDateTimeString = [nowDateTime description];
>
>
but probably you need to customize the date/time string by yourself.
>
If so, you can get a custom date/time string this way:
>
>
NSString *dateFormat = @"Now is: %A, %B %d, %Y - %H:%M:%S";
>
NSString *customDateTimeString = [nowDateTime
>
descriptionWithCalendarFormat:dateFormat];
>
>
And you will get somethisng like:
>
@"Now is: Monday, May 24, 2004 - 08:35:59"
>
>
In "dateFormat" you can write whatever before and after any parameter.
>
For example:
>
the parameter %Y means: year with century (such as 2004)
>
the parameter %d means: the day of the month as a decimal number (01-31)
>
so if you define the variable dateFormat as
>
@"The current year is %Y";
>
you will get the string
>
@"The current year is 2004"
>
>
All the specifiers descriptions for the date format are on your disk at:
>
file:///Developer/Documentation/Cocoa/Conceptual/DataFormatting/Concepts/Dat
>
eFormatters.html#//apple_ref/doc/uid/20000194/CJBFEHBD
>
>
>
Best Regards
>
--
>
Lorenzo
>
email: email@hidden
>
>
>
> Message: 13
>
> Subject: NSCalenderDate
>
> Date: Tue, 25 May 2004 09:39:40 -0400
>
> From: "Patel, Nilesh M" <email@hidden>
>
> To: email@hidden
>
>
>
> I am new to cocoa and have developed a texteditor and was wondering if there
>
> is a way where I can enter the date/time (NSCalenderDate) after I am done
>
> typing a letter, memo, note, etc. I was thinking about setting it up as an
>
> Action button? if so how?
>
>
>
>
==============================================================================
>
The contents of this message, together with any attachments, are intended only
>
for the use of the person(s) to which they are addressed and may contain
>
confidential and/or privileged information. Further, any medical information
>
herein is confidential and protected by law. It is unlawful for unauthorized
>
persons to use, review, copy, disclose, or disseminate confidential medical
>
information. If you are not the intended recipient, immediately advise the
>
sender and delete this message and any attachments. Any distribution, or
>
copying of this message, or any attachment, is prohibited.
>
==============================================================================
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.