-
Notifications
You must be signed in to change notification settings - Fork 7
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
Request: js_of_ocaml example #42
Comments
Ah indeed I've largely forgotten about the js side of usage and it remains unpolished. One outdated example is at https://github.com/daypack-dev/timere-parse-demo But indeed there remains a need for a proper guide. |
Thanks! So it seems the problem is not so much with the timezone database, but that there's no Also, a bit as an aside, I don't really need a tzdb. All I need, and I think this applies to most users, is the local timezone offset. I'll only ever deal with local time for interacting with the end-user, and UTC time for interacting with the server. Is it possible to only create a single fixed-offset time zone, get the current time for that, and deal only with that and UTC? |
Not exactly advisable, but you can do so via picking tzlocal.none or tzlocal.utc backend, and supply your offset based time zone to all relevant calls via Main issue is as soon as any extrapolation into future can cause error when you cross DST boundary. We experimented with dynamic lookup at here https://github.com/daypack-dev/doodlinator/blob/main/bookmarklet/crawler.ml#L24 which retrieves the relevant tzdb-json file after user specification of time zone selection (granted the tzdb json files should be hosted in some CDN for production). |
True, that probably is a better approach. I'll look into that if it starts becoming a problem. Thanks for the guidance! |
It's actually possible to query the JS environment's own timezone database by abusing the |
It seems this has been made with js_of_ocaml, and platform independence more generally, in mind. But it's not at all clear to me how you would set up a js_of_ocaml project to actually use it. It certainly isn't sufficient to just install and use
timedesc
, as that will try to read files from the file system.I can see there are various backends that can be used, but none that target js_of_ocaml specifically. There's also the
export-js-tzdb-*
executables which do target js_of_ocaml, but I don't see how to connect these with anything else. My guess based on this is that it might require using one of these executables to generate a js bundle of the timezone db, include that in your own code somehow, then create a custom backend to utilize it?In short, would it be possible to provide an example or a more detailed description of how this could be accomplished?
The text was updated successfully, but these errors were encountered: