ActiveSupport::Timezone resets the timezone when calling round on the time #12596

Closed
mayanks opened this Issue Oct 21, 2013 · 7 comments

Comments

Projects
None yet
7 participants
@mayanks

mayanks commented Oct 21, 2013

Let us say we have a time object of ActiveSupport::Timezone with the time set to the 1 hour transition period while switching from DST to normal time. When round method is called on that time, the timezone switches back to DST from non-DST. Following example illustrates the behaviour.

2.0.0-p0 :019 > Time.zone = "Europe/Paris"
 => "Europe/Paris"
2.0.0-p0 :020 > t1 = Time.zone.parse("2013-10-27 02:30:00")
 => Sun, 27 Oct 2013 02:30:00 CEST +02:00
2.0.0-p0 :021 > t2 = t1 + 1.hour
 => Sun, 27 Oct 2013 02:30:00 CET +01:00
2.0.0-p0 :022 > t2.round
 => Sun, 27 Oct 2013 02:30:00 CEST +02:00
2.0.0-p0 :023 >

I first thought it may be a Time.round bug and submitted to ruby-core. But looks like it must be ActiveSupport::Timezone issues.

https://bugs.ruby-lang.org/issues/9032

@pftg

This comment has been minimized.

Show comment Hide comment
@pftg

pftg Oct 21, 2013

Contributor

Confirmed for master and 4.0.1.rc1

Contributor

pftg commented Oct 21, 2013

Confirmed for master and 4.0.1.rc1

@krzysztofbialek

This comment has been minimized.

Show comment Hide comment
@krzysztofbialek

krzysztofbialek Jan 16, 2014

if no one is working on that I would like to take a shot

if no one is working on that I would like to take a shot

@carlosantoniodasilva

This comment has been minimized.

Show comment Hide comment
@carlosantoniodasilva

carlosantoniodasilva Jan 16, 2014

Member

@krzysztofbialek please feel free and go ahead, otherwise it might get closed as stale.

@krzysztofbialek please feel free and go ahead, otherwise it might get closed as stale.

@miguelgraz

This comment has been minimized.

Show comment Hide comment
@miguelgraz

miguelgraz Jan 31, 2014

Contributor

@krzysztofbialek are you working on that one? Do we have any new about it?
I'd like to help with anything =)

Contributor

miguelgraz commented Jan 31, 2014

@krzysztofbialek are you working on that one? Do we have any new about it?
I'd like to help with anything =)

@pixeltrix pixeltrix closed this in 63f8fab Jan 31, 2014

@pixeltrix

This comment has been minimized.

Show comment Hide comment
@pixeltrix

pixeltrix Jan 31, 2014

Member

@miguelgraz sorry to steal your thunder but I suddenly realised that the fix from #12163 could be extended to the general case and you'd probably wouldn't have spotted that so it was quicker for me just to fix it.

Member

pixeltrix commented Jan 31, 2014

@miguelgraz sorry to steal your thunder but I suddenly realised that the fix from #12163 could be extended to the general case and you'd probably wouldn't have spotted that so it was quicker for me just to fix it.

@miguelgraz

This comment has been minimized.

Show comment Hide comment
@miguelgraz

miguelgraz Jan 31, 2014

Contributor

@pixeltrix Not problem at all, I have a bunch of other opened issues in the queue here, will just move to the next one.

Contributor

miguelgraz commented Jan 31, 2014

@pixeltrix Not problem at all, I have a bunch of other opened issues in the queue here, will just move to the next one.

@krzysztofbialek

This comment has been minimized.

Show comment Hide comment
@krzysztofbialek

krzysztofbialek Jan 31, 2014

@miguelgraz I was close ;)
@pixeltrix thanks for clearing this. I will look for some other issue :)

@miguelgraz I was close ;)
@pixeltrix thanks for clearing this. I will look for some other issue :)

@rafaelfranca rafaelfranca removed the stale label Apr 23, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment