-
-
Notifications
You must be signed in to change notification settings - Fork 41
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
TimeZone::system(): support WASM as a platform #56
Comments
I agree support for WASM should be added here. Although I think this is not necessarily "wasm support," but rather, "web browser support." For contexts outside of web browsers, I don't imagine this form of detection (running Javascript code) is what one would want. So I think we'll need to explore in what scenarios this sort of detection should be enabled.
Hmmm. Time zone detection should never panic, even if it's unsupported. The panic message you're getting suggests that |
The
So... it's all over the place. I'm not sure what the "right" conditional is for Jiff. |
No, you're right. I mixed up two problems that happened at the same time. With chrono, I could call
I was wrong above.
I believe it would also work for Node. And I guess it makes sense to let Node handle the platform abstraction in that case. Because if you want to do e.g. Linux/Windows-specific timezone detection from within a Node environment, you would have to go through the JS File-IO/Environment-Variable API. And you would risk getting a different result than other parts of the Node application that might rely on the standard(?) way to retrieve the timezone via But yeah, there might be other systems that you want to run your WASM binaries on. Like wasmtime. But it looks like they don't support timezone retrieval just yet? (see WebAssembly/wasi-clocks#69 where you also commented) |
So the approach Jiff is at least currently taking here is that it should really try to use tzdb for this through the IANA tz identifier. This is why, for example, tzdb is actually bundled into the binary on Windows, because Windows doesn't have a standard installation location of tzdb. And Window's default time zone handling is pretty whacky. Porting this decision over to the web browser case, implies, I think, that Jiff embeds tzdb for use in the browser. But it doesn't need to do this in all cases for The main problem with using "platform" APIs for this is that there generally isn't a universal way of looking up time zone rules for an IANA time zone identifier. It just doesn't exist, which is why Jiff owns the tzdb interaction. What is usually available for the platform is "get me the current local time and its corresponding offset." But that is extremely limited. It doesn't expose the actual time zone identifier and thus provides no way to do DST safe arithmetic. Moreover, it inhibits lossless serialization because you can't encode the time zone identifier because you don't have it. OK, so this issue is somewhat tangled up with a few different things:
For (1) and (2), I think this is just blocked on figuring out the right For (3), I don't think there's really anything to be done here. There just isn't a platform independent way of accessing the IANA Time Zone Database. It's beyond my power to fix. This can be made better by reducing the embedded database size by finishing the For (4), a "minimal" way out of this would be to introduce something like |
Anything that would decrease the size of the tzdb (which I want to have embedded in my wasm binary) would be very welcome! It was definitely a concern when we added
Sorry about that. Let me know if I should open a new ticket for the
Again, if it wasn't clear: I definitely want the full power of jiff 😄
I can't speak for everyone else, but I'm personally fine with this restriction, because looking at |
Great! I think just keeping this as one issue for now is fine. We can create new issues for finer grained problems after getting over this initial hump. I think it sounds like your use case lines up pretty well with Jiff then! Hopefully I can figure out how to finish the I'm working on WASM support now. I spoke with the WASI and wasmtime folks about how best to do this, and the conclusion was I think to copy what the But once you enable |
Correct. We ran into that as well when we embedded Numbat into an IRC bot that used wasmtime for hot-reloading the Numbat "plugin". We currently patched this on our own (using a feature gate) in Numbat (see sharkdp/numbat#460).
Sounds great. If I understand correctly, we would still need to do some feature-switching in Numbat on our own though. Because when we compile Numbat for wasm32-wasi, we should not pass that |
No you'll be fine! It's a feature that only enables But yeah, as my Zulip chat revealed, there really isn't any way of reliably discovering the current time zone on |
This PR basically makes the `wasm{32,64}-unknown-unknown` targets work _almost_ out of the box. All you need to do is enable Jiff's new `js` crate feature. This will cause Jiff to depend on `js-sys` and `wasm-bindgen`. Jiff will then use Javascript APIs to determine the current time and time zone. This PR also includes a new long form guide, `PLATFORM.md`, which describes Jiff's platform support in one central location. (Most information is already in Jiff's API docs, but it's scattered in a variety of places.) Finally, this adds a `wasm32-unknown-unknown` test to CI courtesy of `wasm-pack`. It just does a basic sanity check that the current time and time zone can be retrieved. Fixes #56
This PR basically makes the `wasm{32,64}-unknown-unknown` targets work _almost_ out of the box. All you need to do is enable Jiff's new `js` crate feature. This will cause Jiff to depend on `js-sys` and `wasm-bindgen`. Jiff will then use Javascript APIs to determine the current time and time zone. This PR also includes a new long form guide, `PLATFORM.md`, which describes Jiff's platform support in one central location. (Most information is already in Jiff's API docs, but it's scattered in a variety of places.) Finally, this adds a `wasm32-unknown-unknown` test to CI courtesy of `wasm-pack`. It just does a basic sanity check that the current time and time zone can be retrieved. Fixes #56
This PR basically makes the `wasm{32,64}-unknown-unknown` targets work _almost_ out of the box. All you need to do is enable Jiff's new `js` crate feature. This will cause Jiff to depend on `js-sys` and `wasm-bindgen`. Jiff will then use Javascript APIs to determine the current time and time zone. This PR also includes a new long form guide, `PLATFORM.md`, which describes Jiff's platform support in one central location. (Most information is already in Jiff's API docs, but it's scattered in a variety of places.) Finally, this adds a `wasm32-unknown-unknown` test to CI courtesy of `wasm-pack`. It just does a basic sanity check that the current time and time zone can be retrieved. Fixes #56
This should be fixed in |
While porting Numbat to jiff (sharkdp/numbat#511), I noticed that jiff's timezone detection doesn't work on WASM (
currently panics with "time not implemented on this platform"). I am currently usingiana-time-zone
which supports timezone detection on wasm32 out of the box. I'm opening this ticket since you've mentioned that jiff attempts to support more platforms in the future.Here is how
iana-time-zone
does the detection for Browser/Node based environments: strawlab/iana-time-zone#38. They basically runusing
js_sys
. This is supported in all major browsers.The text was updated successfully, but these errors were encountered: