Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #11563 (new defect)

Opened 1 month ago

Last modified 1 month ago

[PATCH] TzTime should store the underlying Time as UTC

Reported by: turnip Assigned to: geoff@geoffbuesing.com
Priority: normal Milestone: 2.x
Component: Plugins Version: edge
Severity: normal Keywords:
Cc:

Description

I'm still looking into the precise reason why, but basically:

>> TzTime.iso8601("2008-06-10T08:00:00") == TzTime.local(2008, 6, 10, 8)
=> false

Attachments

tz_info_should_store_the_underlying_times_as_utc.diff (3.3 kB) - added by turnip on 04/11/08 12:22:50.

Change History

04/10/08 10:33:00 changed by turnip

Ok here is the problem:

>> iso = TzTime.iso8601("2008-06-10T08:00:00")
=> 2008-06-10 08:00:00 BST
>> local = TzTime.local(2008, 6, 10, 8)
=> 2008-06-10 08:00:00 BST
>> iso == local
=> false
>> iso.to_time
=> Tue Jun 10 08:00:00 +0100 2008
>> local.to_time
=> Tue Jun 10 08:00:00 UTC 2008

TzTime doesn't pay attention to the time zone stored on the underlying Time object, so it doesn't essentially matter that they are different. However, the == method is delegated to the underlying time object via method_missing, which does take the time zone into account. A solution would be to always have the underlying time stored as UTC - a patch is forthcoming.

04/10/08 11:59:01 changed by turnip

  • summary changed from TzTime fails with equality in certain situations to [PATCH] TzTime fails with equality in certain situations.

04/10/08 12:04:41 changed by turnip

  • summary changed from [PATCH] TzTime fails with equality in certain situations to [PATCH] TzTime should store the underlying Time as UTC.

04/10/08 12:35:47 changed by turnip

I've also put the change on github, mainly for my convenience: http://github.com/jonleighton/tz_time/tree/master

04/10/08 15:32:34 changed by turnip

I've slightly updated the patch so that TzTime.at works when it is given as TzTime object as well as a standard Time object.

04/11/08 12:22:50 changed by turnip

  • attachment tz_info_should_store_the_underlying_times_as_utc.diff added.

04/11/08 12:23:46 changed by turnip

I realised that the strip_time_zone method was causing the usecs to be lost from the time. This updated patch fixes that. (You can see all the changes on GitHub.)

04/12/08 15:39:40 changed by david

  • owner changed from core to geoff@geoffbuesing.com.