Skip to content

Jruby 1.7.4 Timezone is inverted when creating a Time object #801

Closed
flyinprogrammer opened this Issue Jun 11, 2013 · 3 comments

3 participants

@flyinprogrammer

So this is awkward. :turtle:

irb(main):001:0> Time.new(2013,4,22,14,18,05,'-05:00')
=> 2013-04-22 14:18:05 +0500
irb(main):002:0> Time.new(2013,4,22,14,18,05,'+05:00')
=> 2013-04-22 14:18:05 -0500

It would appear it's just the printing however, because this is reporting the correct data:

irb(main):005:0> Time.new(2013,4,22,14,18,05,'-05:00').zone
=> "GMT-5"

asarih knows things about this defect:

flyinprogramer: why is Time in jruby inverting the timezone ?
asarih: flyinprogramer: cause it was a bug.
asarih: I thought I fixed it…
asarih: it's not. :-S
@BanzaiMan BanzaiMan was assigned Jun 11, 2013
@pritchie

For completeness. Ruby 1.9.3p429

Time.new(2013,4,22,14,18,05,'-05:00') # => 2013-04-22 14:18:05 -0500
Time.new(2013,4,22,14,18,05,'+05:00') # => 2013-04-22 14:18:05 +0500

# wuh?
Time.new(2013,4,22,14,18,05,'-05:00').zone # => nil
Time.new(2013,4,22,14,18,05,'-05:00').utc_offset # => -18000
@BanzaiMan BanzaiMan added a commit that referenced this issue Jun 16, 2013
@BanzaiMan BanzaiMan Invert UTC offset sign if the object was created with a specific offset
Fixes #801.

When a Date object is created with 7 arguments, where the 7th argument
is the UTC offset, we need to invert the sign for the display since
Java's offset is the opposite of Ruby's.
7a6ae2e
@BanzaiMan BanzaiMan added a commit that referenced this issue Jun 16, 2013
@BanzaiMan BanzaiMan Spec for #801 68ea8f3
@BanzaiMan BanzaiMan added a commit that referenced this issue Jun 16, 2013
@BanzaiMan BanzaiMan Spec for #801 04c4a1d
@BanzaiMan
JRuby Team member

@pritchie By the way, #zone returning non-nil should probably be a separate ticket.

@BanzaiMan BanzaiMan added a commit that referenced this issue Jun 16, 2013
@BanzaiMan BanzaiMan Spec for #801 a4751ed
@BanzaiMan BanzaiMan added a commit that closed this issue Jun 16, 2013
@BanzaiMan BanzaiMan Invert UTC offset sign if the object was created with a specific offset
Fixes #801.

When a Date object is created with 7 arguments, where the 7th argument
is the UTC offset, we need to invert the sign for the display since
Java's offset is the opposite of Ruby's.
6188ee5
@BanzaiMan BanzaiMan closed this in 6188ee5 Jun 16, 2013
@BanzaiMan
JRuby Team member

Never mind that. I fixed #zone, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.