Skip to content

parts

Module Export

instant | date |> (zone: Timezone) => CalendarParts

The local calendar fields of an instant in the given timezone.

Remarks

Every field is local to the zone, so an instant late in the UTC day can already be the following date in an eastward zone.

weekOfYear follows ISO 8601: weeks begin on Monday, and week 1 is the one containing the first Thursday of the year. A date in early January can therefore belong to the final week of the previous year.

See CalendarParts for the full record shape and Weekday for the values weekday can take.

Examples

import 'calendar'
let p = 2026-08-15T22:30:00Z parts 'Europe/Stockholm'
from p
// Returns:
// 22:30 UTC is already the 16th in Stockholm
{
year = 2026,
month = 8,
day = 16,
hour = 0,
minute = 30,
second = 0,
weekday = 'sunday',
weekOfYear = 33,
dayOfYear = 228,
quarter = 3
}

Answering questions the language cannot otherwise express:

import 'calendar'
let p = 2026-08-15T12:00:00Z parts 'Europe/Stockholm'
from p.weekday == 'saturday' or p.weekday == 'sunday'
// Returns:
true
import 'calendar'
from (2026-08-15T12:00:00Z parts 'UTC').quarter
// Returns:
3