Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

TimeWithZone should not accept unrecognized time zones

#6573

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.

Reported by Marc-André Lafortune · March 14th, 2011 @ 02:53 PM

State: open
Milestone: none
Assigned to: Santiago Pastorino Santiago Pastorino
Importance: Low

Activity

  1. Marc-André Lafortune
    Marc-André Lafortune
    • Tag changed from bug active to activesupport, bug, timewithzone

    March 14th, 2011 @ 02:54 PM

  2. Josh Kalderimis
    Josh Kalderimis
    • 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

    March 15th, 2011 @ 11:05 AM

  3. Marc-André Lafortune
  4. Marc-André Lafortune
    Marc-André Lafortune

    Here is my patch.

    {Date}Time#in_time_zone, Time.use_zone and Time.zone= now raise an ArgumentError on invalid timezone arguments.

    Note that I changed test_time_zone_setter_with_invalid_zone which used to imply that Time.zone = "foo" was a no-op. There was no test for in_time_zone nor for use_zone.

    Thanks

    March 16th, 2011 @ 07:20 PM

  5. Josh Kalderimis
    Josh Kalderimis
    • 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

    March 16th, 2011 @ 07:52 PM