NSCalendar Additions

Dates. More than any other data type, the gulf between the initial banality of dates and their true, multifaceted complexity looms terrifyingly large. Combining sub-second precision, overlapping units, geopolitical time zone boundaries, localization differences in both language and grammar, and Daylight Saving shifts and leap year adjustments that literally add and remove whole chunks of time from measured existence, there’s a lot to process.

nshipster.com/nscalendar-additions/

NSCalendar offers many tools for working with dates beyond basic NSDateComponents.

To get components:

For comparisons:

For finding next dates:

To list matches: enumerateDates(startingAfter:matching:options:using:).

For weekends: nextWeekendStartDate(_:interval:options:afterDate:) and rangeOfWeekendStartDate(_:interval:containingDate:).

It also gives localised names like monthSymbols, shortMonthSymbols, and standalone versions for grammar rules in some languages.


Category:

Year: