Skip to content

NSDate category to handle date ranges like, start of last week, end of last week

Notifications You must be signed in to change notification settings

Nimbleworks/dateRanges

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

NSDate+dateRanges

Date Ranges is an NSDate category to help get start and end dates of a date unit such as day, week, month or year. So, [[NSDate date] startOfDay] that returns an NSDate at the start of the current day. [[NSDate date] endOfDay] will return a date at the end of today.

What's it for?

Ever need to create a CoreData predicate that searches for something within a range, like yesterday, tomorrow or next week? Now just use this category.

What Can I do?

Get the Previous, Current or Next

  • day
  • week
  • month
  • year

Along with any offset for days, weeks, months and years. So given the date 29 April 1901 I can use the following methods

[date endOfDayWithOffset:10000] to get then end of the 10000th day after 29 April 1901.

Alternatively I could use [date endOfYearWithOffset:50] to get a date and time at the end of 1951.

Technical Notes

This is a command line utility for running a few examples, clone the project and copy NSDate+dateRange.h and NSDate+dateRange.m into your project. These are ARC files, so if you're not using ARC, it's probably best to fork it and do your own memory management.

About

NSDate category to handle date ranges like, start of last week, end of last week

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published