Re: NSCalendar date calculation anomaly
Re: NSCalendar date calculation anomaly
- Subject: Re: NSCalendar date calculation anomaly
- From: Kubernan <email@hidden>
- Date: Wed, 28 Apr 2010 09:04:07 +0200
Le 28 avr. 2010 à 05:45, Scott Ribe a écrit :
>
> It seems as though some calls are using one time zone and some are using another??? I do not do anything in my app to set a local or default time zone, and I have not changed the time zone in my system preferences in a very long time. (Multiple reboots ago.) Add to that, the code did produce the correct date a few times earlier tonight... Also, it doesn't seem to make a difference whether I use systemTimeZone or localTimeZone.
>
Did you try to use NSDateComponents for building your reference date (2001/01/01) such as :
NSCalendar *cal = [NSCalendar currentCalendar];
NSDateComponents *refDateComps = [[NSDateComponents alloc] init];
[refDateComps setYear:2001];
[refDateComps setMonth:01];
[refDateComps setDay:01];
[refDateComps setHour:0];
[refDateComps setMinute:0];
[refDateComps setSecond:0];
NSDate *refDate = [cal dateFromComponents:refDateComps];
[refDateComps release];
NSDateComponents *dc = [[[NSDateComponents alloc] init] autorelease];
[dc setDay: numdays];
NSDate * cd = [cal dateByAddingComponents: dc toDate: refDate options: 0];
K._______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden