Skip to Content
Objective-C
book

Objective-C

by Jiva DeVoe
February 2011
Intermediate to advanced
400 pages
8h 15m
English
Wiley
Content preview from Objective-C

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Beginning Objective-C

Beginning Objective-C

James Dovey, Ash Furrow
More iPhone Development with Objective-C

More iPhone Development with Objective-C

David Mark, Jayant Varma, Jeff LaMarche, Alex Horovitz, Kevin Kim

Publisher Resources

ISBN: 9780470479223Purchase book