Utilities Module

Date Utilities (date)

Comprehensive temporal library for timestamps, calendar arithmetic, and relative time.

Seconds vs. Milliseconds
XyPriss automatically detects if a timestamp is in seconds (Go native) or milliseconds (JS native). Numbers below 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).

typescript
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.

typescript
// 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.

typescript
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.

typescript
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.

typescript
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.

typescript
const week = __sys__.utils.date.dateRange("2026-01-01", "2026-01-07");
.today()

Current Date instance

.weekNumber()

ISO 8601 week

.isLeapYear()

Check for 366 days

.isValid()

Finite date check

Data Utilities

Explore deep object cloning and advanced array management.