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.new with explicit timezone string will display as UTF with +00:00. #5400

Closed
enebo opened this Issue Nov 1, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@enebo
Copy link
Member

commented Nov 1, 2018

jruby -e 'time = Time.new(2013, 2, 20, 0, 0, 0, "+00:00"); p time'

We display:

2013-02-20 00:00:00 UTC

MRI displays:

2013-02-20 00:00:00 +0000

If we supply anything else we match MRI:

jruby -e 'time = Time.new(2013, 2, 20, 0, 0, 0, "+10:00"); p time'
2013-02-20 00:00:00 +1000

@enebo enebo added this to the JRuby 9.2.1.0 milestone Nov 1, 2018

@headius

This comment has been minimized.

Copy link
Member

commented Nov 1, 2018

I think this fixes it. Does not appear to break any tests.

diff --git a/core/src/main/java/org/jruby/RubyTime.java b/core/src/main/java/org/jruby/RubyTime.java
index bbb95bca6a..e8fb1aae85 100644
--- a/core/src/main/java/org/jruby/RubyTime.java
+++ b/core/src/main/java/org/jruby/RubyTime.java
@@ -777,7 +777,7 @@ public class RubyTime extends RubyObject {
 
     private String inspectCommon(final DateTimeFormatter formatter, final DateTimeFormatter utcFormatter) {
         DateTimeFormatter simpleDateFormat;
-        if (dt.getZone() == DateTimeZone.UTC) {
+        if (dt.getZone() == DateTimeZone.UTC && !isTzRelative) {
             simpleDateFormat = utcFormatter;
         } else {
             simpleDateFormat = formatter;

headius added a commit to headius/jruby that referenced this issue Nov 1, 2018

@enebo enebo closed this in #5402 Nov 2, 2018

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.