[ruby-core:121066] [Ruby master Bug#21141] `Time#utc?` does not work with a timezone object

Issue #21141 has been reported by nobu (Nobuyoshi Nakada). ---------------------------------------- Bug #21141: `Time#utc?` does not work with a timezone object https://bugs.ruby-lang.org/issues/21141 * Author: nobu (Nobuyoshi Nakada) * Status: Open * Backport: 3.1: REQUIRED, 3.2: REQUIRED, 3.3: REQUIRED, 3.4: REQUIRED ---------------------------------------- ```ruby 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")`. -- https://bugs.ruby-lang.org/

Issue #21141 has been updated by nobu (Nobuyoshi Nakada). Maybe also this is related: ```ruby 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? ---------------------------------------- Bug #21141: `Time#utc?` does not work with a timezone object https://bugs.ruby-lang.org/issues/21141#change-111983 * Author: nobu (Nobuyoshi Nakada) * Status: Open * Backport: 3.1: REQUIRED, 3.2: REQUIRED, 3.3: REQUIRED, 3.4: REQUIRED ---------------------------------------- ```ruby 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")`. -- https://bugs.ruby-lang.org/

Issue #21141 has been updated by maximecb (Maxime Chevalier-Boisvert). Should we backport this minor doc change? ---------------------------------------- Bug #21141: `Time#utc?` does not work with a timezone object https://bugs.ruby-lang.org/issues/21141#change-112385 * Author: nobu (Nobuyoshi Nakada) * Status: Closed * Backport: 3.1: REQUIRED, 3.2: REQUIRED, 3.3: REQUIRED, 3.4: REQUIRED ---------------------------------------- ```ruby 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")`. -- https://bugs.ruby-lang.org/

Issue #21141 has been updated by nagachika (Tomoyuki Chikanaga). Backport changed from 3.1: REQUIRED, 3.2: REQUIRED, 3.3: REQUIRED, 3.4: DONE to 3.1: REQUIRED, 3.2: REQUIRED, 3.3: DONE, 3.4: DONE ruby_3_3 commit:4ca521e91342165ed35cb12c9868f10e2a6aa07c merged revision(s) commit:06919949a60b42a8f30e8bd0cb075e17b05eebcd, commit:51bc992822f9108ad64de32d300e1cefd0e2da59, commit:42daa6c2a2b49b4e45f40736e25c7d182860f24a. ---------------------------------------- Bug #21141: `Time#utc?` does not work with a timezone object https://bugs.ruby-lang.org/issues/21141#change-112653 * Author: nobu (Nobuyoshi Nakada) * Status: Closed * Backport: 3.1: REQUIRED, 3.2: REQUIRED, 3.3: DONE, 3.4: DONE ---------------------------------------- ```ruby 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")`. -- https://bugs.ruby-lang.org/
participants (3)
-
maximecb (Maxime Chevalier-Boisvert)
-
nagachika (Tomoyuki Chikanaga)
-
nobu (Nobuyoshi Nakada)