Re: NSDate
Re: NSDate
- Subject: Re: NSDate
- From: Scott Anguish <email@hidden>
- Date: Thu, 5 Feb 2004 01:50:11 -0500
On Feb 5, 2004, at 1:01 AM, Laurent Daudelin wrote:
>
on 05/02/04 00:39, April Gendill at email@hidden wrote:
>
>
> Is it possible to take a string such as 2/04/04 and compare it to an
>
> NSDate object?
>
>
>
> so far I simply cannot seem to get the string into something that
>
> would
>
> allow me to compare or sort or anything.
>
>
>
>
NSCalendarDate *firstDate = [NSCalendarDate dateWithString:aString
>
calendarFormat:[[NSUserDefaults standardUserDefaults]
>
objectForKey:NSShortDateFormatString]];
>
>
if ([firstDate earlierDate:secondDate] == firstDate)
>
[self doSomething];
>
>
NSCalendarDate also includes time, so unless the NSDate that is
preexisting is in the same time-zone, and has the same time specified
as is provided by NSCalendarDate when no time is in the string, that's
not going to work reliably.
One solution might be to convert the string to a sortable format of a
date (YYYY-MM-DD), and then have a category on NSDate return a string
formatted similarly, and then you could sort/compare those with the
usual string beasties.
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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.
References: | |
| >Re: NSDate (From: Laurent Daudelin <email@hidden>) |