Question

I was playing around with NSCalendar and NSDateComponents today and I saw constants like NSDayCalendarUnit and NSEraCalendarUnit. NSDayCalendarUnit returns 4 if today is the 4th of December for instance. NSEraCalendarUnit returns the era which is apparently 1 at the time of posting. Anyone care to explain what an era is?

Était-ce utile?

La solution

@Eimantas has it correct. It's AD/BC (or BCE and C.E. for non-Religious folks).

There's a bit more information about it in Apple's Date and Time Programming Guide (linked there). Look under the "Special Considerations for Historical Dates" section.

And the Date & Time Programming Guide's Historical Dates page has even more information, including on working with eras with backward time flow (i.e. the day which follows December 31, 7 BC is January 1, 6 BC).

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top