• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Comparing dates
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


References: 
 >Comparing dates (From: Chad Armstrong <email@hidden>)

  • Prev by Date: Re: Cocoa XML-RPC Framework
  • Next by Date: Populating NSTableView from data source
  • Previous by thread: Comparing dates
  • Next by thread: Controlling soft page breaks in multiple text views
  • Index(es):
    • Date
    • Thread