Date Utilities (date)
Comprehensive temporal library for timestamps, calendar arithmetic, and relative time.
100,000,000,000 are treated as seconds and bridged automatically..now() / .nowMs()
Helpers to get the current system time in the preferred unit (seconds or milliseconds).
const sec = __sys__.utils.date.now();
const ms = __sys__.utils.date.nowMs();.format(date, locale?, options?)
The primary method for localized date serialization. Handles ISO strings, Date objects, and numeric timestamps seamlessly.
// From a XHSC timestamp (seconds)
__sys__.utils.date.format(1776287197, "fr-FR", { dateStyle: "long" });
// → "15 avril 2026".timeAgo(date, locale?)
Returns a localized relative time string (e.g., "15 minutes ago") relative to the current instant.
const lastAction = Date.now() - 1000 * 60 * 15;
__sys__.utils.date.timeAgo(lastAction); // → "15 minutes ago".add(date, value, unit)
Performs calendar-aware arithmetic. Correctly handles month-length variations and leap years.
const subDate = new Date("2026-01-31");
const nextBilling = __sys__.utils.date.add(subDate, 1, "mo");
// → "2026-02-28" (Automatically clamped to end of February).diff(dateA, dateB, unit?)
Returns the signed integer difference between two dates in the requested unit.
const days = __sys__.utils.date.diff("2026-12-25", "2026-12-20", "d"); // → 5.dateRange(start, end)
Generates an array of Date objects for every calendar day between start and end. Capped at 3,650 days.
const week = __sys__.utils.date.dateRange("2026-01-01", "2026-01-07");Current Date instance
ISO 8601 week
Check for 366 days
Finite date check
Explore deep object cloning and advanced array management.
