-
Notifications
You must be signed in to change notification settings - Fork 14
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
Changes to timezones API #69
Comments
Yep! Here's more:
|
Thanks @yoshuawuyts. I'm happy to stay involved with this. My goal with the timezone PR was to support Rust crates and binaries that use the |
Justin already covered most of the feedback I'd have given. I have only a minor thing to add. I'd recommend avoiding the name |
I'm not anything close to expert in timezones or clocks. If @justingrant and @ptomato have a proposal for the timezone interface, then I would be happy to implement it. The only requirements I can see are as follows:
For context, this is @sunfishcode's original PR #32 and associated issue #25. Additionally, this interface is designed to mirror the Rust chrono crate. https://docs.rs/chrono/latest/chrono/
The goal is to address this open issue: WebAssembly/WASI#167
As I said, I'm a novice in this area. What would the host bindings provide other than the system timezone? The iana_time_zone crate outputs the system timezone. Here is how that is determined on Linux: https://github.com/strawlab/iana-time-zone/blob/main/src/tz_linux.rs.
The parameter to utc-offset is a duration from the Unix epoch, which I think is the same thing
It is in the wasi::clocks package and is at the same level of the hierarchy as wall-clock. It might be useful to identify what need from the host beyond the duration from the Unix epoch, the system timezone, and a monotonic clock. If something is lacking there, then we can add more host calls and shape what this interface should look like.
Once again, I don't know what we need from the host than what is provided in this interface. Any manipulation of these values would occur on the component side, and libraries which manipulate those values would be language specific.
|
A "wall clock time" in the language of the Temporal proposal for JS is a date and time, such as you might see on a literal clock on a literal wall. An "instant" or "exact time" is a particular point in time (ignoring leap seconds), not associated with a time zone. (This is also the terminology used in Java. Go's docs use "instant" in the same way, though it doesn't come through in any of the APIs.) In this proposal "wall clock time" appears to be used to mean a particular point in time, not associated with a time zone - i.e., what is elsewhere called an "instant" precisely by contrast to "wall clock" time. I think it's pretty confusing to refer to a particular point in time not associated with any timezone as a "wall clock" time or a "datetime", given that it corresponds neither to a wall clock nor to a date and time. Renaming This proposal does use the term "instant", but not to mean an exact time; that's also going to be confusing. (I'm guessing this is after Rust's |
Unfortunately, the wall clock and monotonic clock wit definitions are part of the WASI 0.2 and are stable (ie no longer "proposed") interfaces. Therefore it would probably not be worth the effort to change the property names. @sunfishcode or @yoshuawuyts are would be better suited to assess the situation than me. The timezone interface is still unstable and can be modified. Would it be too much to ask for you to create a PR with your proposed changes to timezone.wit? You mentioned using nanoseconds instead of seconds for |
It's going to be pretty hard to make these APIs coherent if the names I mentioned above can't be fixed. Is anyone relying on the stable APIs yet? Is there a process by which the old names could be deprecated and replaced? |
Hey all; I'm just now catching up on this conversation again. My understanding is that there may even be changes which should be made to presently stable parts of the I think before we discuss a migration path, the most helpful thing now would be to take the constraints outlined in this issue and translate them to a concrete WIT definition. Assuming we can make any necessary changes, what should the ideal |
I'd be happy to attempt that. I don't have a lot of experience with the WASM component model or WIT, but I think with a bit of reading up I could put something together that we could discuss further. |
I've started something in #71. This is mostly the renames and adjustments suggested in this thread. In each commit I've also suggested several other alternatives for each rename, so bikeshed away! 😄 Taking @cdmurph32's requirement 2 (it must be possible to implement the Rust crates There are a couple of notes in the PR about things we might want to examine further. For example, Continuing thinking about requirement 2, I'd additionally suggest that |
I see @BurntSushi has just released a new Rust crate for handling date/times. Above it is listed as a goal of this API that it should be possible to implement the @BurntSushi sorry for the ping, but in case you're interested in wasm / wasi support for date-time stuff, you may wish to take a look at this issue / #71. |
I don't have a ton of context here, but all Jiff needs is the IANA time zone identifier. Then it will use whatever tzdb is available to it ( It sounds like this is already the direction y'all are heading, so this seems fine? |
I haven't been involved in these discussions but I see that IANA isn't explicitly referenced in the current interface docs: Lines 38 to 47 in 289bc58
I imagine in the long run we'd like some kind of interface to a platform's native tzdb. |
On Unix, you'd just need to allow read access to |
I think ideally we'd want to avoid coupling wasi-clocks timezone info to the wasi-filesystem interface, but given how ubiquitous that approach is I think it could be reasonable for an interface to be a very close approximation of reading a file, something like |
To be clear, I'm saying that I don't think the wasi-clocks interface needs to include anything about tzdb except access to the system IANA identifier (and, I guess, the current offset from UTC). Access to the system's tzdb can be accomplished through wasi-filesystem already (at least on Unix).
(Also, side point, many platforms including the web don't really provide access to tzdb.) |
Yeah I believe that's all that's needed. You could even say that the format of the data returned ought to be compliant with RFC 8536. To say more about what's at stake here, I think a resolvable TZ identifier is the most important thing. Or stated more abstractly, "a way to access the time zone transition rules currently configured for the end user's system." Just an identifier will require callers to go look that up in a database somewhere, which might not be consistent with the user's actual time zone transitions. For example, Ukraine recently voted to abolish DST. So as things currently stand, Ukrainians won't have DST in 2025. Maybe the user's tzdb is up-to-date, but the callers' tzdb is perhaps different and lagging behind. But this is a somewhat rare occurrence. Just the TZ identifier will lead to correct results most of the time. However, if you also provide a way to interface with the system's tzdb in a way that is connected with the TZ identifier, then you eliminate the possibility of this error condition. If you don't provide a TZ identifier at all, then it is effectively impossible to implement DST safe arithmetic on datetime values, because there's no real way to know the time zone transition rules for the user's current locale. So just the TZ identifier alone is a big value-add. With all that said, yes, I agree, there is no uniform access to tzdb across platforms today. So I imagine that would be a thorny thing to traverse. The only platform that really supports it AFAIK is Unix. |
I guess it depends on what the use cases that this timezones API is intended to support? If the goal is only to report the current system time zone, then the IANA ID, the current timestamp, and the current offset should be enough. However, if the goal is also to support time-zone-aware date/time arithmetic (e.g. "the same local time 6 months in the future") then I agree with @BurntSushi that you'll also need: the ability to convert between exact time (nanoseconds since UNIX epoch) and local time in a particular time zone. Which one is the goal of this API?
Yep. Also, platforms like Node and Chrome bundle their own copy of TZDB separate from the system's copy. Other platforms like Safari use the system's copy of TZDB. Note that bundled data is not typically accessible from userland code, and if it is then it's usually not (never?) in TZIF format. As an aside, I'm in the very early stages of working with @leftmostcat on a TC39 proposal to add declarative custom time zones into ECMAScript to replace the non-declarative custom time zones that we recently removed from the Temporal proposal. So far, the most promising standard we've found to expose IANA time zone rules (or any time zone rules, for that matter) isn't TZIF. Instead, we're optimistic about the JSON time zone rule schema defined in JSCalendar (RFC 8984). This standard's data should be semantically interchangeable with TZIF but should be easier to parse. |
If/when y'all get a public space for this project, please ping me. I'd love to watch progress. :-) |
Following up on #68 and #61 (comment), we likely want to make changes to the
@unstable
timezone proposal based on feedback. This is exactly what the unstable status of this extension was for, so I'm happy we're able to iterate on it - thanks to everyone who has provided feedback so far!Current API
Summary of challenges
in-daylight-saving-time
cannot be (easily) implemented in the browser Implementingin-daylight-saving-time
flag #68in-daylight-saving-time
has corner cases, and probably should not just be provided as a boolean isDST() of Africa/El_Aaiun returns incorrect value despite UTC offset difference moment/moment-timezone#968cc/ @justintgrant - did I summarize your feedback accurately in this issue?
The text was updated successfully, but these errors were encountered: