Plugins - TZInfo Timezone

StarAdd to favorites

This plugin installs a replacement for the TimeZone class. The replacement uses the TZInfo library (http://tzinfo.rubyforge.org) to do the time zone conversions, and thus takes into account daylight saving, for free.

It is not a 100%-compatible replacement, however. If you use TimeZone#unadjust anywhere, you'll need to replace those calls, possibly with #local_to_utc. Also, the #adjust method is deprecated--it is better (and easier to read) if you use the #utc_to_local method instead.

Note that you will need to have the tzinfo library installed separately--it is not bundled with this plugin. You can easily install tzinfo as a gem:

gem install tzinfo

http://dev.rubyonrails.org/svn/rails/plugins/tzinfo_timezone/

Rails' (MIT)

  • Currently 4.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Misc. Enhancements

Tags

Comments

Add a comment
Dave 24 Jan 2008

Andrew: It may be due to you using composedof on the timezone. Composedof seems to freeze

Try changing the tzinfo of tzinfo_timezone.rb method to

def tzinfo MAPPING[@name] = TZInfo::Timezone.get(MAPPING[@name]) if String === MAPPING[@name] return MAPPING[@name] end

thus avoiding the frozen @tzinfo.

Used it at own risk, but works for me at least.

Matt M 24 Nov 2007

You can also check our extension of TZInfo, which lets you do the following in models for auto conversion:

hastimezone :fields => [:startdatetime, :end_datetime]

http://hackd.wordpress.com/2007/11/23/sexy-time-zones-in-ruby-on-rails-with-timezone_fu/

Andrew Kaspick 28 Jun 2007
Does anybody ever get this? I can't seem to find any reason why this happens, but it doesn't occur all the time. can't modify frozen object #{RAILS_ROOT}/vendor/plugins/tzinfo_timezone/lib/tzinfo_timezone.rb:215:in `tzinfo' #{RAILS_ROOT}/vendor/plugins/tzinfo_timezone/lib/tzinfo_timezone.rb:193:in `local_to_utc'
Chris Hapgood 15 Mar 2007

This plugin really improves life for i18n apps. But, many developers have been using TZInfo "manually" for some time and have invested in attributes (on User or Account, etc.) to track the TZInfo timezone by name. Furthermore, some find the TZInfo zone names to be more intuitive.

It would be great if this plugin would accept the TZInfo timezone names as well. I offer my patched version. See http://cho.hapgoods.com/wordpress/?p=140

Search Plugins

Query syntax

Plugins by Category

Sponsors

Rails Kits: Get Code. Get Moving.
Recruiting software

Have a comment?