WebAssembly / WASI

WebAssembly System Interface
Other
4.75k stars 243 forks source link

WASI interface for accessing timezone offsets? #467

Open ColinEberhardt opened 2 years ago

ColinEberhardt commented 2 years ago

A little while back I started work on implementing the new TC39 Temporal standard in AssemblyScript. The non-timezone aware parts of this API were relatively easy to implement (see assemblyscript-temporal), however, the more interesting timezone-aware parts of the API are more challenging!

My initial attempt has been to store the IANA timezone database a part of the module, but this results in a sizeable binary, and decoding the IANA timezone files isn't much fun (see assemblyscript-temporal-tz).

Most environments where WebAssembly will be run will already have this timezone information available as part of the OS, so rather than include it within the wasm module, it makes sense access this information from the host, via WASI (calling it, for example, wasi-tz)

The WASI information that supports this would be very simple, the Temporal API can be implemented based on a single method offsetForTimezone(tz: string, epochMillis: i64): i32. Although wasi-tz would probably need methods that allow you to enumerate supported timezones also.

What does this community think of this idea? Is there value in wasi-tz?

tschneidereit commented 2 years ago

I think this would make a lot of sense to do, yes. I also like that it's readily virtualizable via a wasm component containing the required data, so by including that one can run content depending wasi-tz in environments that don't already provide the required information.

ColinEberhardt commented 2 years ago

Thanks @tschneidereit - sounds like it might be worth moving this forwards as a proposal?

Good point about virtualizing via a wasm component.