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

Timezone#now returns local time as UTC #79

Closed
minstrel opened this Issue Nov 22, 2017 · 1 comment

Comments

Projects
None yet
1 participant
@minstrel

minstrel commented Nov 22, 2017

v1.2.4
datasource - same results under both :ruby (tzinfo-data gem v1.2017.3) and :zoneinfo (Debian Stretch)

expected behavior: when calling #now on a Timezone object, it will return the current time in the timezone with proper offset

actual behavior: when calling #now on a Timezone object, it returns the local time with 0 offset - IE if the current local time is 13:00:00 -0500, it returns instead 13:00:00 0000 (aka 13:00:00 UTC).

tz = TZInfo::Timezone.get('America/New_York')
=> #<TZInfo::DataTimezone: America/New_York>

tz.period_for_local(Time.now).offset
=> #<TZInfo::TimezoneOffset: -18000,0,EST>

(America/New_York is also my local computer time, so Time.now and tz.now should return identical Time objects)

puts Time.now;
puts Time.now.utc;
puts tz.now;
2017-11-22 13:58:26 -0500
2017-11-22 18:58:26 UTC
2017-11-22 13:58:26 UTC

@minstrel

This comment has been minimized.

Show comment
Hide comment
@minstrel

minstrel Nov 22, 2017

Sorry I see this is a duplicate of #36.

minstrel commented Nov 22, 2017

Sorry I see this is a duplicate of #36.

@minstrel minstrel closed this Nov 22, 2017

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