Skip to content

Time#to_s with different UTC offset gives local hour with given offset #1517

@jgaskins

Description

@jgaskins
$ jruby -v
jruby 1.7.10 (2.0.0p195) 2014-01-09 c4ecd6b on Java HotSpot(TM) 64-Bit Server VM 1.7.0_17-b02 [darwin-x86_64]

My UTC offset is -05:00. When I create a time with UTC offset +05:00, it adds 10 hours, but displays it with the given offset.

t = Time.new(2014, 1, 2, 3, 4, 5, '+05:00').to_s
# Expected: 2014-01-02 03:04:05 +0500
# Actual  : 2014-01-02 13:04:05 +0500

The actual hour is correct when you run time.hour, but the string rendering is off.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions