std/time/calendars▲toc

Various calendars\: TAI, GPS, ISO week, Julian, Coptic, etc.

.

val cal-coptic: calendarstd/time/calendar/calendar: V

The Coptic calendar. The calendar short name is CC.

val cal-ethiopian: calendarstd/time/calendar/calendar: V

The Ethiopian calendar. The calendar short name is EC.

val cal-iso-month: calendarstd/time/calendar/calendar: V

This is not a standard ISO calendar – it is named this way because it is based directly on the standard ISO week date calendar. The short name of the calendar is "IM".

The “ISO month” calendar takes the ISO week calendar as is, but divides it up in 12 months. This is more familiar than using week numbers to denote a date. A common ISO week year of 52 weeks is divided into 4 quarters of 13 weeks each. Each quarter has 3 months of 30, 30, and 31 days respectively. So, January has 30 days, February has 30 days too, March has 31 days, April has 30 days again, etc. On a leap year, we have an extra leap week 53 that is inserted at the end of the last month, i.e. adds days 32 to 38 to December. Since quarters are meant to be equal for business purposes, we generally don't count the leap week as part of the 4th quarter.

This monthly calendar has many good properties, not the least that it matches the Gregorian calendar dates very closely1, and is based a widely supported standard ISO calendar. Moreover, it is perennial where every date in the year always has the same weekday. For example, every year and every quarter always start on a Monday and end on a Sunday. Thanksgiving (the 4th Thursday of November) is always on November 23, and always 31 days before Christmas. Christmas and New year are always on Sunday, and there is never a Friday the 13th.

When writing down a date in the monthly calendar we prefix the month with a capital M in order to distinguish these dates from regular Gregorian dates or ISO week dates. For example,

Day Gregorian date Month date Remarks ISO week date
Mon 2018-01-01 2018-M01-01 Matches since Monday starts the first week of the year. 2018-W01-1
Thu 2016-11-24 2016-M11-23 Thanksgiving, always on Thursday M11-23 every year. 2016-W47-5
Thu 2013-07-04 2013-M07-04 Independence day is always on Thursday M07-04. 2013-W27-4
Thu 2004-01-01 2004-M01-04 Since the first week falls partly in 2003M. 2004-W01-4
Sun 2005-01-02 2004-M12-38 Since it is the last day of the leap week of 2004M. 2004-W53-7

With the regularity of the new calendar, we can reuse the same calendar pattern for each quarter over and over; unlike the Gregorian calendar it never changes which makes planning for businesses, schools, government etc. much simpler. Here is the (perpetual) calendar with the corresponding ISO week numbers:

Quarterly Calendar ISO week numbers
1 2 3 4 5 6 7 1 14 27 40
8 9 10 11 12 13 14 2 15 28 41
15 16 17 18 19 20 21 3 16 29 42
22 23 24 25 26 27 28 4 17 30 43
29 30 5 18 31 44
1 2 3 4 5 5 18 31 44
6 7 8 9 10 11 12 6 19 32 45
13 14 15 16 17 18 19 7 20 33 46
20 21 22 23 24 25 26 8 21 34 47
27 28 29 30 9 22 35 48
1 2 3 9 22 35 48
4 5 6 7 8 9 10 10 23 36 49
11 12 13 14 15 16 17 11 24 37 50
18 19 20 21 22 23 24 12 25 38 51
25 26 27 28 29 30 31 13 26 39 52
 32 33 34 35 36 37 38 leap week 53

 

A leap week is inserted at the end of December. Upcoming years with a leap week are 2020, 2026, 2032, 2037, and 2043. In general, a leap week is inserted whenever the corresponding Gregorian year starts and/or ends on a Thursday.

– Daan Leijen, 2016.

val cal-iso-week: calendarstd/time/calendar/calendar: V

The ‘ISO week’ calendar. This implements the ISO week date calendar the week number is interpreted as “month” number instead, i.e. every year has 52 (or 53) months of 7 week days each. Short name is "IW".

Since its introduction in 1988, the ISO week calendar is a widely accepted standard for a weekly calendar. It is used mainly by businesses for fiscal year calculations. Weeks start on Monday (as day 1) and every common year has 52 weeks. Every 5 to 7 years, there is a ‘leap’ year with an extra week 53. The ISO week calendar is directly based on the Gregorian calendar. For example, Tuesday 2001-01-02 is denoted as 2001-W01-2 in the ISO week calendar: weekday 2 (Tuesday) of week 1 in 2001.

The year of an ISO week is defined as the Gregorian year that has the Thursday of that week, i.e. contains the most days of that week. For example, Thursday 2004-01-01 has week date 2004-W01-4. This means that sometimes the Gregorian year is different for a first- or last week: Wednesday 2003-12-31 falls in the first week of 2004W and has week date 2004-W01-3. Similarly, Saturday 2005-01-01 falls in the last (leap) week of 2004W and has week date 2004-W53-6.

val cal-jg: calendarstd/time/calendar/calendar: V

The combined Julian / Gregorian calendar, using the Julian calendar for dates before 1582-10-15 and the Gregorian calendar otherwise. It is possible to specify a different switch date using the julian-gregorianstd/time/calendars/julian-gregorian: (switch-date : ? date) -> calendar function. The calendar short name is JG.

val cal-julian: calendarstd/time/calendar/calendar: V

The Julian calendar. Uses old-style BC and AD to display era's. The calendar short name is JC.

fun julian-gregorian( switch-date : ? datestd/time/date/date: V ) : calendarstd/time/calendar/calendar: V
private import std/core/typesstd/core/types, std/core/hndstd/core/hnd, std/core/exnstd/core/exn, std/core/boolstd/core/bool, std/core/orderstd/core/order, std/core/charstd/core/char, std/core/intstd/core/int, std/core/vectorstd/core/vector, std/core/stringstd/core/string, std/core/sslicestd/core/sslice, std/core/liststd/core/list, std/core/maybestd/core/maybe, std/core/eitherstd/core/either, std/core/tuplestd/core/tuple, std/core/showstd/core/show, std/core/debugstd/core/debug, std/core/delayedstd/core/delayed, std/core/consolestd/core/console, std/corestd/core, std/time/instantstd/time/instant, std/time/utcstd/time/utc, std/time/datestd/time/date, std/time/calendarstd/time/calendar

1.The month date always matches within 5 days of the Gregorian calendar; and 90% of the time, the date is within 3 days.