Ruby 'gem tzinfo'

2019-09-05 16:17发布

问题:

From my previous question about timezones, I decided to use the Ruby gem tzinfo to get access to time zone data. This means storing scheduled times as a timezone name (e.g. "America/Toronto"), and then using the Ruby tzinfo gem and tzinfo database to look up the correct UTC time from a desired local time.

My understanding is that the database of time zones changes from time to time because different jurisdictions call for different policies on the (non)application of Daylight Savings Time.

Once I install the Ruby gem tzinfo, how do I keep the time zone database up to date?

Also, are time-zones ever dropped from the database?

回答1:

From tzinfo.rubyforge.org:

 The tz database is compiled into Ruby modules which are packaged in the release.

So just keeping the gem up to date (with gem update tzinfo) should be sufficient to ensure your timezone files are current.

I don't know whether time zones are ever dropped from the database; I've never noticed dropped timezones myself but to be honest I haven't been looking that hard.