Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

local_to_utc should return UTC when system time is UTC #13

Closed
hamiltop opened this issue Jan 10, 2014 · 1 comment
Closed

local_to_utc should return UTC when system time is UTC #13

hamiltop opened this issue Jan 10, 2014 · 1 comment

Comments

@hamiltop
Copy link

Because of the way Ruby handles timezones we can find ourselves in a position where a Time object is non-utc but has a timezone of UTC. If the system timezone utc, we get the following

irb(main):013:0> Time.now.utc?
=> false
irb(main):014:0> Time.now.zone
=> "UTC"

If we use such a time object in calling local_to_utc, the is a bug in https://github.com/tzinfo/tzinfo/blob/master/lib/tzinfo/time_or_datetime.rb#L52

In that line we check for UTC in the zone. I propose we check the utc? method instead of checking the zone method.

The result is that local_to_utc may return a non-utc Time object with zone UTC. With the proposed fix we should always be returning a utc Time object.

I'm happy to submit the fix. Just wanted some feedback first.

@philr philr closed this as completed in ac59588 Jan 11, 2014
@philr
Copy link
Member

philr commented Jan 11, 2014

Thank you for the bug report.

I have committed a fix (changed to use utc? instead of zone as you propose).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants