Skip to content

Time#zone using Time#local #1795

@robin850

Description

@robin850

Hello,

We've discovered an inconsistency of JRuby with MRI when dealing with time zones. The behavior is kind of weird on MRI anyway but we wanted with @febuiles to bring a discussion around this. Time.local supports ten parameters for historical reasons (when dealing with #to_a for instance) but the passed time zone is ignored and MRI and Rubinius returns the current time zone:

>> time = Time.local(0, 30, 1, 30, 10, 2005, 0, 0, false, 'US/Eastern');

>> RUBY_ENGINE
=> "ruby"
>> time.zone
=> "CEST" # In my case

>> RUBY_ENGINE
=> "rbx"
>> time.zone
=> "CEST"

However, JRuby has a sightly different behavior that isn't the same between JRuby 1.7.12 and 1.7.13:

>> JRUBY_VERSION
=> "1.7.12"
>> time.zone
=> nil

>> JRUBY_VERSION
=> "1.7.13"
>> time.zone
=> "EDT"

The returned time zone is wrong anyway because EDT stands for "Eastern Daylight Time" while false has been passed as the ninth parameter (i.e. isdst).

To bring JRuby in line with MRI and Rubinius, these lines should not be reached when we are calling Time#local.

Have a nice day!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions