If you’ve got an app that utilizes dates, and events then you’re going to need to make adjustments for user time differences and calendar differences.
Mattt Thompson has created CupertinoYankee, an NSDate category that enhances NSDate to gather locale aware date information using NSCalendar and NSDateComponents to handle any complex calculations.
Provided are methods for gathering the beginning and end of the day, week, month or year based on the user’s locale.
Here’s an example as shown on the readme – entering:
NSLog(@"Beginning of Day:%@", [date beginningOfDay]);
NSLog(@"End of Day:%@", [date endOfDay]);
NSLog(@"Beginning of Week:%@", [date beginningOfWeek]);
NSLog(@"End of Week:%@", [date endOfWeek]);
NSLog(@"Beginning of Month:%@", [date beginningOfMonth]);
NSLog(@"End of Month:%@", [date endOfMonth]);
NSLog(@"Beginning of Year:%@", [date beginningOfYear]);
NSLog(@"End of Year:%@", [date endOfYear]);
Provides the result:
Beginning of Day: 2012-04-16 07:00:00 +0000
End of Day 2012-04-17 06:59:59 +0000
Beginning of Week: 2012-04-16 07:00:00 +0000
End of Week: 2012-04-23 06:59:59 +0000
Beginning of Month: 2012-04-01 07:00:00 +0000
End of Month: 2012-05-01 06:59:59 +0000
Beginning of Year: 2012-01-01 08:00:00 +0000
End of Year: 2013-01-01 07:59:59 +0000
You can find CupertinoYankee on Github here.
A nice simple category making it easier to make adjustments for the user’s locale.
- NSDate Category Makes Using It Bearable
- Open Source Tool For Automatically Graphing Objective-C Class/Instance Details
- How Many Downloads It Takes To Hit The Top 25 In Each App Store Category
- Open Source: In App Location Maps Using Any Map Source
- Open Source: Category For Easy Embedding Of PDF Images In iOS Apps For Scalable Images
Original article: NSDate Add-On Category For Easily Obtaining Locale Adjusted Date Information
©2013 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.





