-
Notifications
You must be signed in to change notification settings - Fork 570
LoadLocation Call in time package #64
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
Comments
I believe there was a similar issue in the past: |
Yes, the timezone information is read from disk on all platforms. This means that in the current state, it will never work in a browser. Having timezone information would be quite useful, right? Theoretically we could take the content of $GOROOT/lib/time/zoneinfo.zip and turn it into a virtual file system stored in a Go file, but the compressed size is 351K, so this would be quite big. Another option is to use http://momentjs.com/timezone/ . It seems to include most of the timezone data in a very compressed format. So we need a wrapper that loads the data from this library into the |
I just added support for the local timezone (so |
I am currently working on this. moment.js' data compression process is well documented, and it should be simple to embed it inline. |
@ajhager How is the progress on this issue? Does the moment.js approach work? |
Closing this issue for now, since there is nothing for me to do about it right now. Please reopen if required. |
Since nothing has changed on this front in more than 2 years, maybe it is time to just include zoneinfo.zip. Maybe only if time is imported or even only if LoadLocation is called. I am not sure if the latter is doable, but the former should be. The compilation results are already pretty large (even a small demo is typically >100k compressed), so conditionally adding 300k doesn't sound completely crazy to me. |
It might be that by using an alternate compression algorithm might allow us to reduce the size burden somewhat. On my system, zoneinfo.zip is 360k. By recompressing with 'zip -9', it is reduced to 300k. By using gzip (on the original. zip), it is reduced to 96k. I'm not sure what the best combination would be, for size/performance, but I don't think we need to be stuck with adding 360k to a bundle just to use timezones. |
I didn't think of that. I tried a bunch of combinations (with the decompressed data, then tar, then compression). Looks like around 100k is the lower end with the stuff that is supported directly in go (gzip -9). With xz or 7z it goes down to 50k. Compressing the zip instead of a tar adds 10% for xz, but maybe that is worth it to avoid touching the internals of LoadLocation. tldr: Using xz on the zip gives 55k. Leaving this to transport compression would be convenient, but is not an option I guess, since that'll be bad for https. |
I'm not sure how lightweight the decompressor for xz is compared to gz, zip, etc. If it's possible to use a browser's built-in gzip decompressor, then using gz offers a huge advantage. But I'm not sure how realistic that is. |
I'll reopen this issue for better visibility since there's renewed interest in resolving this in some way. But we still need to find an acceptable solution, and I'm not sure if adding 100 KB or more (if it needs to also include decompression code) is acceptable. |
my 2 cents: utilise moment.js and it's timezone package. https://momentjs.com/timezone/ |
Go now has built-in support for embedding the time zone database statically from within in the standard library. https://golang.org/pkg/time/tzdata/ This might just work as-is (haven't checked), or could be used as a trigger the same way in GopherJS to tell it to include the optimized moment db. Browser support for IANA timezones has also gotten better. I'm not sure if the browser exposed APIs now cover the needs of |
Related: #989 |
I believe that I'm going to close this issue now, but if anyone thinks this is a mistake — please let me know. |
the "time.LoadLocation" call causes a System call, at least on Windows.
I don't know how hard it is to implement this, but could you at least
make a hint in the compatibility doc ?
The text was updated successfully, but these errors were encountered: