7.5.16.3 SRFI-19 Date

A date object represents a date in the Gregorian calendar and a time of day on that date in some timezone.

The fields are year, month, day, hour, minute, second, nanoseconds and timezone. A date object is immutable, its fields can be read but they cannot be modified once the object is created.

Historically, the Gregorian calendar was only used from the latter part of the year 1582 onwards, and not until even later in many countries. Prior to that most countries used the Julian calendar. SRFI-19 does not deal with the Julian calendar at all, and so does not reflect this historical calendar reform. Instead it projects the Gregorian calendar back proleptically as far as necessary. When dealing with historical data, especially prior to the British Empire’s adoption of the Gregorian calendar in 1752, one should be mindful of which calendar is used in each context, and apply non-SRFI-19 facilities to convert where necessary.

Function: date? obj

Return #t if obj is a date object, or #f if not.

Function: make-date nsecs seconds minutes hours date month year zone-offset

Create a new date object.

Function: date-nanosecond date

Nanoseconds, 0 to 999999999.

Function: date-second date

Seconds, 0 to 59, or 60 for a leap second. 60 is never seen when working entirely within UTC, it’s only when converting to or from TAI.

Function: date-minute date

Minutes, 0 to 59.

Function: date-hour date

Hour, 0 to 23.

Function: date-day date

Day of the month, 1 to 31 (or less, according to the month).

Function: date-month date

Month, 1 to 12.

Function: date-year date

Year, eg. 2003. Dates B.C. are negative, eg. -46 is 46 B.C. There is no year 0, year -1 is followed by year 1.

Function: date-zone-offset date

Time zone, an integer number of seconds east of Greenwich.

Function: date-year-day date

Day of the year, starting from 1 for 1st January.

Function: date-week-day date

Day of the week, starting from 0 for Sunday.

Function: date-week-number date dstartw

Week of the year, ignoring a first partial week. dstartw is the day of the week which is taken to start a week, 0 for Sunday, 1 for Monday, etc.

Function: current-date [tz-offset]

Return a date object representing the current date/time, in UTC offset by tz-offset. tz-offset is seconds east of Greenwich and defaults to the local timezone.

Function: current-julian-day

Return the current Julian Day.

Function: current-modified-julian-day

Return the current Modified Julian Day.