temporal icon indicating copy to clipboard operation
temporal copied to clipboard

Human Formatting of Temporal Values

Open neoeinstein opened this issue 3 months ago • 1 comments

I was interested in investigating this crate as a potential replacement for my usage of chrono and chrono_tz, but noted that it doesn't have any facility for formatting a date in a human-readable form. I presume that the idea would be to use the icu_datetime and icu_locale crates as the basis for doing that, but is there a recommended "ramp" for converting Temporal values into the appropriate ICU types?

Could Temporal provide appropriate functions (perhaps gated behind a feature flag) that either allowed conversion to those ICU types or access to the ICU formatters?

neoeinstein avatar Sep 26 '25 13:09 neoeinstein

Hi! Thanks for taking a look at temporal_rs!

As of right now, there is not a way to serialize to a locale string.

Personally, I would very much like to have to_locale_string methods supported in some way for all primary types using icu_datetime as the underlying implementation. This would have to be behind a feature flag, because some engines use ICU4C's datetime formatting. That being said, while temporal_rs ultimately is meant to support ECMAScript implementations, it's also a way to use the Temporal API in Rust. Not supporting to_locale_string would mean that the temporal_rs's Rust API is not covering the entirety of the Temporal API.

There's some caveats to this though. Ideally, the implementation of to_locale_string should be ECMA402 compliant. Although, I could imagine a world where there is an intermediate method that translate to the different ICU formatters that allow more configuration than whatever "ECMA402 compliant" is, but we'll have to see.

There has been some progress on ECMA402's Intl.DateTimeFormat that began in Boa with boa-dev/boa#4378. As that progresses further, some API will hopefully be made available on temporal_rs to support this in Rust.

Also, thanks for the issues / feedback! If you have questions on anything else, feel free to submit issues 😄

nekevss avatar Sep 26 '25 15:09 nekevss