This project is archived and is in readonly mode.

TimeWithZone should not accept unrecognized time zones
Reported by Marc-André Lafortune | March 14th, 2011 @ 02:53 PM
Currently, the following doesn't raise any error:
t = Time.now.in_time_zone("There is no such timezone"); t.utc
Many other methods of TimeWithZone will raise a
NoMethodError as soon as they try to access the
timezone (e.g. t.inspect).
It should not be possible to create a TimeWithZone with an invalid timezone.
Comments and changes to this ticket
- 
            
         Marc-André Lafortune March 14th, 2011 @ 02:54 PM- Tag changed from bug active to activesupport, bug, timewithzone
 
- 
         Josh Kalderimis March 15th, 2011 @ 11:05 AM- Tag changed from activesupport, bug, timewithzone to activesupport
- State changed from new to open
- Importance changed from  to Low
 Hi Marc-André, I agree with this. Are you able to whip up a patch with tests? Thanks, Josh 
- 
            
         
- 
            
         Marc-André Lafortune March 16th, 2011 @ 07:20 PMHere is my patch. {Date}Time#in_time_zone,Time.use_zoneandTime.zone=now raise anArgumentErroron invalid timezone arguments.Note that I changed test_time_zone_setter_with_invalid_zonewhich used to imply thatTime.zone = "foo"was a no-op. There was no test forin_time_zonenor foruse_zone.Thanks 
- 
         Josh Kalderimis March 16th, 2011 @ 07:52 PM- Assigned user set to Santiago Pastorino
 Hey Marc, I think the patch and tests look good. +1 from me, I prefer having ActiveSupport raise an error if the timezone is incorrect. Santiago, what do you think? Josh 
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
 Jeremy Kemper
      Jeremy Kemper
 Josh Kalderimis
      Josh Kalderimis
 Manfred Stienstra
      Manfred Stienstra
 Piotr Sarnacki
      Piotr Sarnacki
 Santiago Pastorino
      Santiago Pastorino