Skip to content
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

Next release Crystal 0.25.0 will have time zone support in standard library #1

Closed
straight-shoota opened this issue Jun 5, 2018 · 8 comments
Labels
question Further information is requested

Comments

@straight-shoota
Copy link

Crystal's stdlib has had support for time zones since early this year in master and it will be included in the upcoming release Crystal 0.25.0. Maybe you have already taken a look at this? (the process is documented in crystal-lang/crystal#5324)

Most of the features this shard provides are already implemented there, even with a cleaner API (due to being directly integrated in the standard library).

There are a certainly quite a few things this shard offers that are not in the stdlib implementation. For example parsing timezone db files in text format (this is usually not really needed as the binary format is more memory and time efficient). Or integrating country codes to time zones, mostly trivial mapping.

Maybe there are other features as well, that I've missed. Please let me know!

While such features are probably not all suited for the standard library, it would certainly make sense to make them available as shards integrating with the new time zone API in the stdlib.

This could be a good time to join forces and discuss design and implementations of a new time and time zone related shard to provide enhanced features based on the stdlib API.
I'd be happy if you're willing to contribute.

@DmytroStepaniuk
Copy link
Contributor

Moreover. 0.25.0 has breaking changes:

require "time_zone"
^

in lib/time_zone/src/time_zone.cr:19: while requiring "./time_zone/time"

require "./time_zone/time"
^

in lib/time_zone/src/time_zone/time.cr:4: while requiring "./time/canonical_time_instance_methods"

require "./time/canonical_time_instance_methods"
^

in lib/time_zone/src/time_zone/time/canonical_time_instance_methods.cr:4: undefined constant ::Time::Kind

      alias Kind = ::Time::Kind

@straight-shoota
Copy link
Author

@DmytroStepaniuk That actually doesn't matter much because with Crystal 0.25.0 you can just use stdlib's Time::Location API instead of TimeZone::Zone.

@DmytroStepaniuk
Copy link
Contributor

@straight-shoota I was playing with jennifer.cr and that cool tool has dependence on time_zone shard - https://github.com/imdrasil/jennifer.cr/blob/master/shard.yml#L37

@straight-shoota
Copy link
Author

Then you should open an issue there to remove this dependency and replace TimeZone with Time::Location. It looks like this can easily be migrated to use the stdlib API.

@DmytroStepaniuk
Copy link
Contributor

Suddenly, I found that Time::Kind is using in strange way... I would say... Its unused 🤔

Anyway, building time_zone without that error gives another errors:

https://travis-ci.org/DmytroStepaniuk/time_zone/builds/394137156

@DmytroStepaniuk
Copy link
Contributor

DmytroStepaniuk commented Jun 19, 2018

Well. Actually const DAY_NAMES disappeared in 0.25.0 🤔
Something strange happened with including, but I changed it to ::Time::Format::DAY_NAMES this line of code works now 🤔

https://github.com/imdrasil/time_zone/blob/master/src/time_zone/time/parser.cr#L107

@imdrasil
Copy link
Owner

imdrasil commented Jul 5, 2018

Mostly all features of this shard are included stdlib - that's true. But there still several useful methods (like getting the current time from the time zone instance). Jennifer v0.6.0 will not have this shard as a dependency anymore. At this stage, I'm thinking about transforming this shard to only provide up-to-date data in .cr files (ready to be used without reading) and several useful patches of stdlib. In this way, everyone can get access to the latest data without manual downloading data.

@imdrasil imdrasil added the question Further information is requested label Jul 5, 2018
@straight-shoota
Copy link
Author

@imdrasil You mean a repository of time zone database in Crystal files similar to tzinfo-data in Ruby? I'm not sure about this...

As far as I can tell, it would be better to include the time zone database in binary format if you need to ship a copy of it compiled into a Crystal executable. This can be read by the stdlib implementation very efficiently and is probably more space efficient. Most importantly, it doesn't rely on maintaining a custom copy of the database as Crystal shard (it needs to be updated infrequently, several times a year). There might be advantages of having the database in Crystal code available, but I fail to see any significant ones.

Useful feature can certainly be discussed to be included in the stdlib. Maybe we can take a look at what would fit there and what is better left in a shard?

It's great to see that jennifer.cr works with the new stdlib Time implementation 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants