Chapter 15. Working with Times and Dates
In This Chapter
Manipulating dates with NSDate and NSCalendar
Working with time intervals
Localizing dates
Working with dates on computers is traditionally a complex proposition. Dates, despite appearances, are not nearly as simple as they might seem. They're filled with exceptions and edge conditions, such as leap years, calendar changes, and so on. A comprehensive consideration of the subject reveals that even taking into consideration these exceptions, there are still issues surrounding questions of how far back your calendar should go and what to do with dates that fall before that boundary, and so on. The CE/BCE standard which we are accustomed to is really a fairly ineffective kludge.
If you need more proof of how difficult working with dates can be, recall the Y2K problem that the computing industry experienced at the beginning of this century. Naïve programmers had previously thought that they could represent the year in dates using only two digits. When the century mark rolled over, millions of lines of code had to be rewritten.
Even now, we face future problems with dates due to the fact that most computers store their dates using 32-bit integers as a count of seconds since January 1, 1970. Unfortunately, this counter will roll over sometime in the year 2032. Although that may seem far away, I remind you that programmers said the same things about the year 2000 when they were writing their two-digit year handling code.
Even if you ignore ...
Get Objective-C now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.