Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSCalendar bug with adding to pre-1919 dates?



Ah yes, I'm sure that's the problem. I will simply change the year value each time rather than using -[NSCalendar dateByAddingComponents:frequency:toDate:options:].

Thanks for the help!
Ben

On Feb 28, 2006, at 5:41 PM, Ryan Britton wrote:

DST maybe?  http://en.wikipedia.org/wiki/Daylight_saving_time

"Then on March 19, 1918, the U.S. Congress established several time zones (which were already in use by railroads and most cities since 1883) and made daylight saving time official (which went into effect on March 31)"


On Feb 28, 2006, at 3:06 PM, Ben Kazez wrote:

I have an application that retrieves an NSCalendarDate from a .ics file and adds one year to it until the date is within a certain range. (This isn't the most efficient way to do things, but it's fast enough for my needs.) This algorithm runs into a problem with dates before 1919. Here's the line that adds the date components:

currentExpandedDate = [[IEPSystemCalendar dateByAddingComponents:frequency toDate:currentExpandedDate options:0] dateWithCalendarFormat:BKWebScriptCalendarFormat timeZone:[[unexpandedEvent objectForKey:@"DTSTART"] timeZone]];

The frequency variable is set to one year using -[NSDateComponents setYear:]. As an example, here the app is starting with 1914-03-01 00:00:00 -0600:

March 01, 1915 00:00:00
March 01, 1916 00:00:00
March 01, 1917 00:00:00
March 01, 1918 00:00:00
March 01, 1919 01:00:00
March 01, 1920 01:00:00
...

(Sorry for the inconsistent date formatting.) As you can see, after 1918, the date is one hour off. Does anyone know why this is happening?

Ben
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >NSCalendar bug with adding to pre-1919 dates? (From: Ben Kazez <email@hidden>)
 >Re: NSCalendar bug with adding to pre-1919 dates? (From: Ryan Britton <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.