Calendar · Modules | Program

Modules · Data · Calendar

Dates, times and date-times. Calendar provides three plain data types — Calendar.Date for a calendar day, Calendar.Time for a time of day (or duration) held as seconds, and Calendar.DateTime pairing the two. Each type doubles as a pseudo-module that groups its own operations: a constructor, field accessors, and JSON conversion. Every value is reactive, so a derived year or a formatted month name recomputes whenever the date it reads changes.

A calendar day as a year, month and day. It also groups the date operations.

A combined date and time. It also groups the date-time operations.

A time of day, or a duration, held as a total number of seconds. It also groups the time operations.

The current day of the month from the system clock.

Returns Maths.Integer — the current day of the month.

The current month from the system clock.

Returns Maths.Integer — the current month, 1 to 12.

The current year from the system clock.

Returns Maths.Integer — the current calendar year.

Builds a date from a year, month and day.

Returns Calendar.Date — a date carrying the given fields.

Reads a date back from a JSON value.

Returns Calendar.Date — the date parsed from the JSON, filling missing fields with defaults.

Reads a date from an optional JSON value, propagating absence.

Returns Collection.Optional(Calendar.Date) — the parsed date, or nothing when the input is absent.

Reads the day field of a date.

Returns Maths.Integer — the day of the month of data .

Reads the month field of a date.

Returns Maths.Integer — the month of data , 1 to 12.

Reads the year field of a date.

Returns Maths.Integer — the year of data .

The English name of a month number.

Returns Text — the English month name, or an empty text when the number is out of range.

Serialises a date to a JSON value.

Returns Code.Language.Json.Value — an object with year , month and day fields.

Combines a date and a time into a date-time.

Returns Calendar.DateTime — the paired date and time.

Reads a date-time back from a JSON value.

Returns Calendar.DateTime — the date-time parsed from the JSON.

Reads a date-time from an optional JSON value, propagating absence.

Returns Collection.Optional(Calendar.DateTime) — the parsed date-time, or nothing when the input is absent.

Reads the date component of a date-time.

Returns Calendar.Date — the date part of data .

Reads the time component of a date-time.

Returns Calendar.Time — the time part of data .

Serialises a date-time to a JSON value.

Returns Code.Language.Json.Value — an object holding the date and time.

Builds a time from a total number of seconds.

Returns Calendar.Time — a time holding totalSeconds .

Reads a time back from a JSON value.

Returns Calendar.Time — the time parsed from the JSON.

Reads a time from an optional JSON value, propagating absence.

Returns Collection.Optional(Calendar.Time) — the parsed time, or nothing when the input is absent.

Reads the total-seconds field of a time.

Returns Maths.Real — the seconds held by data .

Serialises a time to a JSON value.

Returns Code.Language.Json.Value — an object with a totalSeconds field.

Recommended articles