I am using the js_sys
crate to run some Rust code in the browser.
Having difficulty to understand how to use Intl::DateTimeFormat
.
All I want is to get the local timezone, which is done with this JS code:
const tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
This does not seem to work in Rust:
let tz = Intl::DateTimeFormat().resolved_options().time_zone();
--> src/lib.rs:14:14
|
14 | let tz = Intl::DateTimeFormat().resolved_options().time_zone();
| ^^^^^^^^^^^^^^^^^^^^ did you mean `Intl::DateTimeFormat { /* fields */ }`?
It seems to want me to create a new DateTimeFormat
struct, but I just want to get the "default" one, if there's such thing...
How can I get this to work?