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

Time#zone when no zone is known #5785

Closed
zverok opened this issue Jul 6, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@zverok
Copy link

commented Jul 6, 2019

Environment

$ jruby -v
jruby 9.2.5.0 (2.5.0) 2018-12-06 6d5a228 OpenJDK 64-Bit Server VM 25.212-b03 on 1.8.0_212-8u212-b03-0ubuntu1.18.04.1-b03 +jit [linux-x86_64]
$ uname -a
Linux platypus 4.15.0-54-generic #58-Ubuntu SMP Mon Jun 24 10:55:24 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Expected Behavior

On MRI (any version), when Time's utc_offset is specified as a number, Time#zone returns nil

t = Time.new(2019, 6, 1, 0, 0, 0, 3*3600) # => passing offset explicitly makes it lack symbolic zone
# => 2019-06-01 00:00:00 +0300
t.zone # => nil

Actual Behavior

On JRuby (specified version), it returns "" (empty string).

t = Time.new(2019, 6, 1, 0, 0, 0, 3*3600)
# => 2019-06-01 00:00:00 +0300
t.zone
# => "" 

# Using text offset works as expected:
Time.new(2019, 6, 1, 0, 0, 0, '+03:00').zone
# => nil 

It is obviously very edge-case scenario, and never explicitly specified in Time's docs, but MRI's behavior seems more consistent, and JRuby's way requires special handling in some cases.

@enebo enebo added this to the Invalid or Duplicate milestone Jul 8, 2019

@enebo

This comment has been minimized.

Copy link
Member

commented Jul 8, 2019

This was fixed in 9.2.7.0.

@enebo enebo closed this Jul 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.