Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to obtain the system's UTC offset #239

Open
jhpratt opened this issue Mar 2, 2020 · 2 comments
Open

Ability to obtain the system's UTC offset #239

jhpratt opened this issue Mar 2, 2020 · 2 comments
Labels
feature-request Requests for new WASI APIs

Comments

@jhpratt
Copy link

jhpratt commented Mar 2, 2020

See bytecodealliance/wasmtime#1200. It would be great to be able to obtain both the system's current UTC offset and the offset at a particular moment in time.

Related?: #25

@MaxGraey
Copy link

Any progress with this? By the way, great review from Colin Eberhardt about time zones and IANA:
https://blog.scottlogic.com/2021/09/14/120-years-timezone.html

@ricochet
Copy link
Contributor

wasi-clocks did not have a goal of implementing timezones. It implemented clock_time_get. There is a similar libc API gettimeofday that is used to surface both the time and timezone. We could consider re-visiting wasi-clocks and add a record for timezone and an API that surfaces it.

Then we would likely want to add to wasi-libc so that the following POSIX code works:

let mut tp = std::mem::MaybeUninit::<libc::timeval>::uninit();
let tz = std::ptr::null_mut::<libc::timezone>();
let is_error = unsafe { libc::gettimeofday(tp.as_mut_ptr(), tz) };

A totally different approach would be to surface a higher-level set of APIs like the Internationalization API Specification. The handle to clock in WASI-clocks gives runtimes a capability-driven approach to allowing system time reads. In this theoretical DateTimeFormat API, it could be a handler to intl or still a clock (as intl will almost definitely need to depend on wasi-clocks). It feels too granular to do this just for getting a timezone. I suggest naming this proposal wasi-intl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Requests for new WASI APIs
Projects
None yet
Development

No branches or pull requests

4 participants