json
JSON Parse & Manipulate
Parse, build, and edit JSON. Backed by serde_json in Rust, nested get/set, merge, and pretty-print included.
- parse & stringify
- Dot-path access
- Deep merge
- Pretty-print
Wall-Clock & Time Zones
Core Standard Library
time is for anything wall-clock related: log timestamps, scheduling, parsing ISO dates from an API. now() gives you the current instant; format and parse use strftime-style patterns.
Timezone conversion goes through IANA names (America/New_York, Asia/Tokyo) with daylight saving rules baked in via chrono-tz. You can add durations, diff two instants, and compare datetimes without rolling your own calendar math.
Import
import "time" |
Quick start
import "time" |
|
let now = time.now() |
let formatted = time.format(now, "%Y-%m-%d %H:%M:%S %Z") |
let tokyo = time.to_timezone(now, "Asia/Tokyo") |
High-level overview of what time is for.
Convert an instant to another zone by name. DST transitions are handled by the tz database, not hard-coded offsets.
%Y-%m-%d, %H:%M:%S, %Z, and the usual directives for logs and user-facing dates.
Construct a specific date/time, read out year/month/day/hour/minute/second, compare two values.
Add a duration, measure the gap between two instants, parse ISO-8601 strings from wire formats.
44 functions and methods in time. Grouped by category from the standard library docs.
| Signature | Description |
|---|---|
| time.now_unix_ms() | Unix epoch milliseconds (wall clock) |
| time.now_unix_s() | Unix epoch seconds |
| time.now_iso() | RFC 3339 string in UTC |
| time.now_iso_local() | RFC 3339 string in local timezone |
| time.now(tz?) | Datetime object (`tz` defaults to `"local"`) |
| Signature | Description |
|---|---|
| time.format(ms, fmt, tz?) | Format timestamp (`tz` defaults to `"UTC"`) |
| time.parse(text, fmt, tz?) | Parse string → unix ms (`tz` defaults to `"UTC"`) |
| time.to_iso(ms, tz?) | ISO 8601 with offset |
| Signature | Description |
|---|---|
| year | Calendar year |
| month | 1–12 |
| day | 1–31 |
| hour | 0–23 |
| minute | 0–59 |
| second | 0–59 |
| millisecond | 0–999 |
| weekday | 0 = Monday … 6 = Sunday |
| weekday_name | e.g. `"Friday"` |
| unix_ms | Original timestamp |
| timezone | e.g. `"UTC"`, `"local"`, `"Asia/Kolkata"` |
| utc_offset_ms | UTC offset in milliseconds |
| Signature | Description |
|---|---|
| time.from_parts(year, month, day, hour?, minute?, second?, ms?, tz?) | Build unix ms from parts (`tz` defaults to `"local"`) |
| time.decompose(ms, tz?) | Split timestamp into datetime object |
| Signature | Description |
|---|---|
| time.add_ms(ms, delta) | Add milliseconds |
| time.add_seconds(ms, delta) | Add seconds |
| time.add_minutes(ms, delta) | Add minutes |
| time.add_hours(ms, delta) | Add hours |
| time.add_days(ms, delta) | Add days |
| time.diff_ms(a, b) | Returns `a - b` in milliseconds |
| Signature | Description |
|---|---|
| time.utc_offset_ms(tz, ms?) | UTC offset in ms at `ms` (default: now) |
| time.list_timezones() | Sorted list of IANA timezone names |
| Signature | Description |
|---|---|
| time.is_leap_year(year) | Leap year check |
| time.days_in_month(year, month) | Days in month (1–12) |
| time.is_valid_date(year, month, day) | Valid calendar date |
| time.start_of_day(ms, tz?) | Midnight in timezone |
| time.end_of_day(ms, tz?) | 23:59:59.999 in timezone |
| Signature | Description |
|---|---|
| time.year(ms, tz?) | Year component |
| time.month(ms, tz?) | Month component |
| time.day(ms, tz?) | Day component |
| time.hour(ms, tz?) | Hour component |
| time.minute(ms, tz?) | Minute component |
| time.second(ms, tz?) | Second component |
| time.weekday(ms, tz?) | Weekday 0–6 (Mon–Sun) |
| time.weekday_name(ms, tz?) | Weekday name |
| Signature | Description |
|---|---|
| time.sleep_ms(ms) | Block for `ms` milliseconds |
More from Core Standard Library.
JSON Parse & Manipulate
Parse, build, and edit JSON. Backed by serde_json in Rust, nested get/set, merge, and pretty-print included.
File & Path I/O
Read and write files, stream large inputs, and work with paths. Blocking I/O can run on background threads.
Regular Expressions
Regular expressions via Rust's regex crate. Match, split, replace, and compile patterns once for hot loops.