Re: Comparing dates
Re: Comparing dates
- Subject: Re: Comparing dates
- From: John Cate <email@hidden>
- Date: Sat, 28 Feb 2004 13:25:47 -0600
On Feb 28, 2004, at 12:54 PM, Chad Armstrong wrote:
I'm working on some beta software and I want it to expire after a
certain date. The last time I tried this, it would occasionally
expire before the selected time, and I could not find out why this was
happening. What would be the best method to do this? I am assuming
that NSCalendarDate might be the way to go.
To wrap things up, here is some pseudo code of what I'm trying to
accomplish:
expiration_date = "April 16 2004 0:00";
if (current_date isLaterThan: expiration_date)
{
// your taxes are late!
}
This works for me:
NSCalendarDate* expirationDate = [[[NSCalendarDate alloc]
initWithString:@"2004-05-01 00:00:00 +0000"] autorelease];
NSCalendarDate* today = [NSCalendarDate calendarDate];
if([today compare:expirationDate] == NSOrderedDescending){
// Expired
}
Tony
3 Cats And A Mac
http://www.3caam.com
_______________________________________________
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.