Skip to content

time — Overview

The time module provides comprehensive time and date functionality, inspired by Go's time package with Day.js-style fluent APIs.

Module Map

FilePurpose
time_type.vxCore Time struct, calendar accessors, startOf/endOf
duration.vxDuration type with arithmetic
constants.vxMonth and Weekday enums, time unit constants
parse.vxTime string parsing (ISO 8601, RFC 3339, custom formats)
format.vxcTime formatting with layout strings
conversations.vxInternal date math (leap years, epoch conversion)
helpers.vxUtility functions
location.vxTimezone / location support
native.vxcOS clock FFI (monotonic, wall clock)

Quick Start

rust
import { Time, now, Duration, sleep, SECOND, MILLISECOND } from "time";

// Current time
let t = now();
println("Now: {t}");               // 2024-06-15T14:30:00Z
println("Unix: {t.unix()}");       // 1718458200
println("Year: {t.year()}");       // 2024
println("Month: {t.month()}");     // June
println("Weekday: {t.weekday()}"); // Saturday

// Arithmetic
let later = t.add(3600 * SECOND);
let elapsed = t.sub(earlier);

// Sleep
sleep(500 * MILLISECOND);

Released under the MIT License.