Skip to content

UNIX time is not shown correctly #91

@fukuchi

Description

@fukuchi

Timezone#strftime("%s", time) converts the given time to UNIX time. Because UNIX time is the number of seconds that have elapsed since 1970-01-01 00:00:00 (UTC), the result does not depends on the timezone.

However, the result of the folloing code seems incorrect.

#!/usr/bin/ruby

require 'tzinfo'

jst = TZInfo::Timezone.get("Japan")
utc = TZInfo::Timezone.get("UTC")

time = Time.now.utc

puts jst.strftime("%F %T (%Z): %s", time)
puts utc.strftime("%F %T (%Z): %s", time)

The code returned:

2018-08-30 21:18:23 (JST): 1535663903
2018-08-30 12:18:23 (UTC): 1535631503

In the case above, I expecet the result as:

2018-08-30 21:18:23 (JST): 1535631503
2018-08-30 12:18:23 (UTC): 1535631503

I used tzinfo-1.2.3 with Ruby 2.3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions