Skip to content

Conversation

@pull
Copy link

@pull pull bot commented Dec 27, 2025

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

…#1276)

* feat(timezone): add timezone support with minimal Intl.DateTimeFormat

Add lightweight timezone support for LLRT that enables dayjs and similar
libraries to perform timezone conversions without polyfills.

Features:
- Timezone.getOffset() - Get UTC offset for any IANA timezone with DST support
- Timezone.list() - List all available IANA timezone names
- Intl.DateTimeFormat - Minimal implementation with format(), formatToParts(),
  and resolvedOptions() for timezone-aware date formatting
- Date.prototype.toLocaleString - Enhanced to support timeZone option

This addresses issue #814 by enabling native timezone conversions that
previously required polyfills adding 1.2+ seconds of execution time.

Binary size impact: +1.2 MB (IANA timezone database via chrono-tz)

* refactor(timezone): reorganize module structure per review feedback

- Move llrt:timezone API to llrt_core/src/modules/llrt/timezone.rs
  (follows pattern for LLRT-specific modules like llrt:hex, llrt:xml)
- Create modules/llrt_intl for Intl.DateTimeFormat and Date.toLocaleString
  (follows pattern for Node.js compatible modules)
- Remove modules/llrt_timezone (replaced by above split)
- Update Cargo.toml references and module registrations

* refactor(timezone): address PR review feedback

- Remove global Timezone object, now only accessible via module import
  (`import { Timezone } from "llrt:timezone"`)
- Move llrt:timezone type declaration to llrt_core/src/modules/js/llrt.d.ts
  following the pattern for other LLRT modules (hex, xml, qjs)
- Keep Intl.DateTimeFormat global augmentation in types/timezone.d.ts
  following the pattern for feature-specific globals (fetch, navigator)

* perf(intl): optimize DateTimeFormat with itoa and reduce JS bridging

- Refactor format_to_parts to build Rust Vec<FormatPart> first, then
  convert to JsArray, avoiding back-and-forth JS bridging
- Replace format! macro usage with itoa crate for faster number
  conversions
- Extract common formatting logic into format_number() and
  format_component() helpers to reduce code duplication
- Add comprehensive Rust unit tests for formatting functions
- Replace string concatenation with [].concat() pattern for error
  messages

* docs(intl): address PR review feedback

- Add doc comment explaining why locale parameter exists in toLocaleString
- Remove unverified ES Module imports note from README

* feat(intl): add locale-aware date formatting with 31 locales

Implement locale parameter support for Date.prototype.toLocaleString using
baked CLDR patterns. This enables proper locale-aware date/time formatting
without requiring the full ICU library.

Locales supported (31):
- Tier 1 (14): en-US, en-GB, de, fr, es, it, pt, nl, ru, ja, ko, zh, zh-TW, ar
- Tier 2 (8): hi, bn, vi, th, id, tr, pl, uk
- Tier 3 (9): sv, da, nb, fi, cs, el, he, hu, ro

Binary size impact:
- CLDR locale data: ~158 KB total (~5.1 KB per locale)
- chrono-tz timezone data: ~1.1 MB (597 IANA timezones)

Features:
- Locale-specific date/time patterns (M/d/yy vs dd/MM/yyyy vs yyyy/MM/dd)
- Locale-specific month and weekday names
- Locale-specific AM/PM markers
- hour12 default based on locale (12h for en-US, 24h for de-DE)
- dateStyle/timeStyle options support

---------

Co-authored-by: richarddavison <[email protected]>
@pull pull bot locked and limited conversation to collaborators Dec 27, 2025
@pull pull bot added the ⤵️ pull label Dec 27, 2025
@pull pull bot merged commit d0a5da3 into Tiamat-Tech:main Dec 27, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant