Skip to content

Latest commit

 

History

History
24 lines (16 loc) · 1.2 KB

README.md

File metadata and controls

24 lines (16 loc) · 1.2 KB

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.