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

Time zone support #25

Closed
fluffysquirrels opened this issue Jan 26, 2023 · 5 comments · Fixed by #32
Closed

Time zone support #25

fluffysquirrels opened this issue Jan 26, 2023 · 5 comments · Fixed by #32

Comments

@fluffysquirrels
Copy link

I'm working on a project in a WASI context that uses time in local time zones. I see how the API in this proposal would support getting the current time in the UTC time zone, but not in the user's local time zone.

What do you think about adding a new resource that lets the WASI guest fetch the local time zone (e.g. as seconds offset from UTC)? Since the local time zone could be used to fingerprint a user, it makes sense to me to add a resource as a new capability to control access to this.

@sunfishcode
Copy link
Member

Does this use case need access to the timezone database, as is being discussed in WebAssembly/WASI#25, or would it be enough to just return the UTC offset?

@fluffysquirrels
Copy link
Author

In my use case I just need the offset.

In case it helps, I'm trying to patch the rust crate chrono to work in a WASI-like target, currently using some custom component imports based on the interface in this repo.

@fluffysquirrels
Copy link
Author

For completeness, some other prior related issues:

@fluffysquirrels
Copy link
Author

I looked more closely at the implementation of chrono. Internally on Unix it uses a timezone database, but as far as I can tell this data is not exposed and for WASI we could have an alternate implementation just using the UTC offset.

@sdeleuze
Copy link

sdeleuze commented Feb 5, 2023

On Kotlin side, I am leveraging https://github.com/Kotlin/kotlinx-datetime multi-platform library, which seems to require access to the timezone database, see the platform specific functions here.

sunfishcode added a commit to sunfishcode/wasi-clocks that referenced this issue Feb 6, 2023
Add a small timezone API that returns the UTC offset, timezone name, and
daylight saving time status for a given `datetime` timestamp.

This is not a full timezone database API. It's designed so that
implementations that don't wish to do anything with timezones can just
support a single "UTC" time zone, which can be easily implemented.

It's also not a time formatting or locale API. It doesn't say how to
format a human-readable timestamp; it just provides the information that
would typically be formatted into a human-readable timestamp.

This API expects a `timezone` handle argument will be added to the
command entrypoint function, providing programs with a `timezone` to
provide timezone information about wall-clock timestamps.

Fixes WebAssembly#25.
sunfishcode added a commit that referenced this issue Feb 7, 2023
* Add a timezone API.

Add a small timezone API that returns the UTC offset, timezone name, and
daylight saving time status for a given `datetime` timestamp.

This is not a full timezone database API. It's designed so that
implementations that don't wish to do anything with timezones can just
support a single "UTC" time zone, which can be easily implemented.

It's also not a time formatting or locale API. It doesn't say how to
format a human-readable timestamp; it just provides the information that
would typically be formatted into a human-readable timestamp.

This API expects a `timezone` handle argument will be added to the
command entrypoint function, providing programs with a `timezone` to
provide timezone information about wall-clock timestamps.

Fixes #25.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants