On Mac OS X, If you go to system preferences > Date & Time > Open Language and Texts > On the Top click on Formats > and then with the drop down for calendar there is an option for a coptic calendar. How do I display this calendar in a Mac Application?
Share
Well, what do you mean by display? Do you just want to use the coptic calendar in your calculations? If that’s the case then all you need is an appropriate
NSCalendarinstance. SinceNSCalendar(and friends) are backed by the ICU, you can use any identifier that ICU supports (under “Key/Type Definitions”). This means you can choose from among:gregorian– (default)islamic– Astronomical Arabicchinese– Traditional Chinese calendarislamic-civil– Civil (algorithmic) Arabic calendarhebrew– Traditional Hebrew Calendarjapanese– Imperial Calendar (same as Gregorian except for the year, with one era for each Emperor)buddhist– Thai Buddhist Calendar (same as Gregorian except for the year)persian– Persian Calendarcoptic– Coptic Calendarethiopic– Ethiopic CalendarSo to get the
NSCalendarinstance, it’d be a matter of:However, if you actually want to draw some UI (à la iCal), then you need a lot more information. Fortunately, you can get that from the
NSCalendaras well.For example, you’ll need to know how many months the calendar has:
So it looks like every year has 13 months. OK, how about days in a month?
Whoa! It looks like you can have a month that only has 5 days in it! (But no month has more than 30 days) Let’s see if we can find out some more:
This iterates through 20 years, and builds an
NSDatethat corresponds to the first day of each month in each year. It then looks to see how many days are in that month, and logs the result. (Note that1500and1520are arbitrary years that I picked)This logs:
Analyzing this, we see that every month has 30 days, except for the 13th month, which (usually) has 5 days. It appears that once every 4 years, the 13th month has 6 days. That must be how it handles the leap day. This sure is a nice calendar! Everything’s nice and regular.
Let’s poke around some more:
So every day has 24 hours (daylight savings time jumps are not reflected in this range. The Gregorian calendar also reports a minimum hour range of
{0,24}and a maximum hour range of{0,24}, despite some days having 23 hours or 25 hours, depending on the DST transition).Things are also normal at the minute and second level (60 each).
So if you’re wanting to display the calendar yourself, you’ll need a UI that can handle 13 months in a year, one of which is less than a week long. At the sub-day level, things are what we’re used to.
Of course, you can also go read the Wikipedia article on the Coptic Calendar.
Edit (based on the comment)
If all you want to do is to format a date as a string, then you’ll (of course) turn to
NSDateFormatter: