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

Add a timezone API. #32

Merged
merged 3 commits into from
Feb 7, 2023

Conversation

sunfishcode
Copy link
Member

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.

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.
@ricochet
Copy link
Contributor

ricochet commented Feb 7, 2023

I appreciate that this is a minimal change that will enable many new use-cases to compile, excellent!

In regards to the TODO for using wasi-clocks handle: Is that something that needs to be completed for this PR to be mergable?

Is the intention for this to be settled and available in wasi-preview2?

@sunfishcode
Copy link
Member Author

I appreciate that this is a minimal change that will enable many new use-cases to compile, excellent!

Thanks!

In regards to the TODO for using wasi-clocks handle: Is that something that needs to be completed for this PR to be mergable?

No, we can just focus on the logical behavior of the API here, and leave details like handles to be cleaned up when we update wit-bindgen.

Is the intention for this to be settled and available in wasi-preview2?

Yes, that's my intention.

@sunfishcode
Copy link
Member Author

Ordinarily I'd leave new feature PRs like this open a little longer for comments, but I'm taking the liberty of merging this early to make way for the upgrade to the new repo layout. Comments and questions on this feature are still welcome, here, or in new issues!

@sunfishcode sunfishcode merged commit d66aa0c into WebAssembly:main Feb 7, 2023
@sunfishcode sunfishcode deleted the sunfishcode/timezone branch February 7, 2023 22:43
@oovm
Copy link

oovm commented Feb 19, 2024

It seems that there is still no way to get the time zone in wasi 0.2.0.

Will this be postponed to preview3?

@sunfishcode
Copy link
Member Author

I'm optimistic that we can re-introduce this API in wasi 0.2.1.

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 this pull request may close these issues.

Time zone support
3 participants