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:
In the case above, I expecet the result as:
I used tzinfo-1.2.3 with Ruby 2.3.
The text was updated successfully, but these errors were encountered:
%s was being deferred to the result of the conversion to local. This is actually a UTC instance being used to represent local time, so the result would be the number of seconds since the epoch plus the total UTC offset. Override the handling of %s and use the passed in UTC instance to calculate the value. Resolves #91.
Thanks for the report.
This is already resolved in the upcoming version 2.0.0 release (currently on the master branch).
For earlier versions of TZInfo, this is a consequence of returning UTC instances of Time and DateTime to represent local times in order to support Ruby versions older than 1.9.3 (that can only handle times in the local system time zone and UTC).
I've committed a change to the 1.2 branch to make