From: andrew@... Date: 2016-01-23T18:55:16+00:00 Subject: [ruby-core:73320] [Ruby trunk - Bug #11595] Time#utc? and Time#gmt? return misleading results based on $TZ Issue #11595 has been updated by Andrew Vit. Careful: not every time with offset 0 is UTC. A time zone with offset +0100/-0100 may have DST rules, and should not be `utc?`. ---------------------------------------- Bug #11595: Time#utc? and Time#gmt? return misleading results based on $TZ https://bugs.ruby-lang.org/issues/11595#change-56549 * Author: David Celis * Status: Open * Priority: Normal * Assignee: Akira Tanaka * ruby -v: ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14] * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- There is an issue with Time#utc? and its alias, Time#gmt?, that return misleading results based on the value of the TZ environment variable. It seems that the only way for a Time instance to return `true` for `utc?` is if you explicitly call `#utc` on it before: ~~~ ENV['TZ'] = 'UTC' # => "UTC" time = Time.now # => 2015-10-14 19:30:00 +0000 time.utc? # => false time = time.utc # => 2015-10-14 19:30:00 UTC time.utc? # => true ~~~ This seems misleading based on the value of $TZ being "UTC". The expected result for calling `Time.now.utc?` in this case would be `true`, as would that be expected for time zones that are considered links to "UTC" based on the [tzdata list](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). These include "UTC", "GMT", "Etc/UTC", "Etc/GMT", "Universal", etc. ---Files-------------------------------- time_utc.patch (927 Bytes) -- https://bugs.ruby-lang.org/ Unsubscribe: