Module: time.date

Source: ./time/date.reef


Overview

time/date - Date handling functions

Provides functions for working with dates using the Gregorian calendar. Dates are represented as days since the Unix epoch (1970-01-01). This is more efficient than timestamps for pure date operations.

Usage: import time.date let today = date_today() let year = date_year(today) let tomorrow = date_add_days(today, 1) let formatted = date_format(today)


Functions

fn is_leap_year(year: int): bool

fn days_in_month(year: int, month: int): int

fn days_in_year(year: int): int

fn date_today(): int

fn date_make(year: int, month: int, day: int): int

fn date_parse(s: string): result.Result[int, error.Error]

Parse strict ISO date YYYY-MM-DD. Rejects any deviation: missing zero-pads, non-dash separators, non-digit chars, trailing text, or out-of-range values.

fn days_to_year_yday(total_days: int, out_yday: [int]): int

Internal: convert days to year and day-of-year

fn date_year(date: int): int

fn date_yearday(date: int): int

fn date_month(date: int): int

fn date_day(date: int): int

fn date_weekday(date: int): int

fn date_add_days(date: int, days: int): int

fn date_add_weeks(date: int, weeks: int): int

fn date_add_months(date: int, months: int): int

fn date_add_years(date: int, years: int): int

fn date_diff_days(date1: int, date2: int): int

fn date_before(date1: int, date2: int): bool

fn date_after(date1: int, date2: int): bool

fn date_equal(date1: int, date2: int): bool

fn digit_char(n: int): char

fn date_format(date: int): string

Format as ISO: YYYY-MM-DD

fn date_format_us(date: int): string

Format as US: MM/DD/YYYY

fn date_format_eu(date: int): string

Format as EU: DD.MM.YYYY

fn date_format_long(date: int): string

Format as long: Month DD, YYYY

fn weekday_name(weekday: int): string

fn weekday_name_short(weekday: int): string

fn month_name(month: int): string

fn month_name_short(month: int): string

fn date_week_of_year(date: int): int

ISO week number (1-53) Week 1 is the week containing the first Thursday of the year

fn date_start_of_week(date: int): int

Get Sunday of the current week

fn date_start_of_month(date: int): int

Get first day of the month

fn date_end_of_month(date: int): int

Get last day of the month

fn date_to_timestamp(date: int): int

Convert date to Unix timestamp (midnight UTC)

fn timestamp_to_date(timestamp: int): int

Convert Unix timestamp to date


Generated by reefc doc