Bug #21141 closed
`Time#utc?` does not work with a timezone object
Added by nobu (Nobuyoshi Nakada) about 1 month ago.
Updated 1 day ago.
Description
require 'timezone'
require 'tzinfo'
t = Time . now ( in: "UTC" )
t_timezone = Time . now ( in: Timezone [ "UTC" ])
t_tzinfo = Time . now ( in: TZInfo :: Timezone . get ( "UTC" ))
p t . utc? #=> true
p t_timezone . utc? #=> false
p t_tzinfo . utc? #=> false
This also affects strftime("%-z")
.
Maybe also this is related:
ENV [ "TZ" ] = "UTC"
p Time . now . utc? #=> false
Is it expected?
In other words, is that Time#utc?
is true a special case, only when the time is created with the methods such as Time.utc
, Time#utc
, etc, that clearly return a UTC time object?
Status changed from Open to Closed
Should we backport this minor doc change?
Backport changed from 3.1: REQUIRED, 3.2: REQUIRED, 3.3: REQUIRED, 3.4: REQUIRED to 3.1: REQUIRED, 3.2: REQUIRED, 3.3: REQUIRED, 3.4: DONE
Also available in: Atom
PDF
Like 0
Like 0 Like 0 Like 0 Like 0