A detailed overview of date handling in WebObjects is now available for download in PDF format.
Use Consistent Date Handling
Consistency in date hanlding makes maintaining and fixing date-handling code easier. Apple recommends that you always use the Foundation date and time API's when you need to write date-handling code for OPENSTEP or WebObjects.
Don't Divide By an NSTimeInterval Value
Dates are represented in the Foundation framework with NSDate and NSCalendarDate objects and NSTimeInterval values. An NSTimeInterval object is essentially a C-language double (NSTimeInterval can represent intervals of approximately 10,000 years with sub-millisecond accuracy). NSDate and NSCalendarDate store the date that they represent with an NSTimeInterval which represents the time delta in seconds from the Foundation reference date (00:00:00 Greenwich Mean Time January 1, 2000). Since the internal time representation will transition across zero at the reference date, there will be a brief instant (on the order of microseconds in length) during which an NSDate object created to represent the current time will have an NSTimeInterval of zero. An NSTimeInterval of zero has no special significance to NSDate or NSCalendarDate, but applications that use the NSTimeInterval of a date object in division should protect against division by zero. This is unlikely to occur in real-world applications.
Avoid Two-Digit Date Formats
Always use four-digit years when formatting dates for input or output; a four-digit year is the only unambiguous way to refer to any date. The Foundation framework's date formatting objects may interpret two-digit year values in unexpected ways, and using the two-digit "%y" format allows no way for a user to present a date unambiguously and may cause additional problems; for example, typing "2004" into a two-digit year formatted field result in a value of "20" being used and "04" being truncated. Instead, use the four-digit "%Y" year format.