ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: "nagachika (Tomoyuki Chikanaga)" <noreply@ruby-lang.org>
To: ruby-core@neon.ruby-lang.org
Subject: [ruby-core:110731] [Ruby master Bug#19106] Time - Hour 24 with tzinfo to_s bug
Date: Sun, 13 Nov 2022 02:23:29 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-100066.20221113022328.52545@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-19106.20221105200548.52545@ruby-lang.org

Issue #19106 has been updated by nagachika (Tomoyuki Chikanaga).

Backport changed from 2.7: REQUIRED, 3.0: REQUIRED, 3.1: REQUIRED to 2.7: REQUIRED, 3.0: REQUIRED, 3.1: DONE

ruby_3_1 728d9f18348bcffedb0880c67015f08a7c19665f merged revision(s) 011d4c57d21220249600dfb76db84840550da019.

----------------------------------------
Bug #19106: Time - Hour 24 with tzinfo to_s bug
https://bugs.ruby-lang.org/issues/19106#change-100066

* Author: ruby-gregor (Greg Lindstrom)
* Status: Closed
* Priority: Normal
* ruby -v: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x64-mingw-ucrt]
* Backport: 2.7: REQUIRED, 3.0: REQUIRED, 3.1: DONE
----------------------------------------
There appears to be a bug when using Time with tzinfo and setting hour to 24. I contacted tzinfo on github where a repository contributor investigated and thought it was an issue with the Time module and not tzinfo. This person had some insight: https://github.com/tzinfo/tzinfo/issues/142


```ruby
require 'time'
require 'tzinfo'

# Time without tzinfo

puts Time.new(2022, 11, 6, 24, 0, 0)
# => 2022-11-07 00:00:00 -0600
puts Time.new(2022, 11, 6, 24, 0, 0).strftime("%Y-%m-%d %H:%M:%S %z")
# => 2022-11-07 00:00:00 -0600

# Time with tzinfo
tz = TZInfo::Timezone.get("America/Chicago")

puts Time.new(2022, 11, 6, 24, 0, 0, tzinfo=tz)
# => 2022-11-06 23:00:00 -0600      <== bug, off by one hour

puts Time.new(2022, 11, 6, 24, 0, 0, tzinfo=tz).strftime("%Y-%m-%d %H:%M:%S %z")
# => 2022-11-07 00:00:00 -0600
```

I expect all the string outputs above should match (first two depends on your system timezone). The inconsistent issue appears to happen when using Time with hour = 24 and with tzinfo set and implied calling to_s versus strftime. Time addition appears to produce the correct result.

ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x64-mingw-ucrt]
tzinfo (2.0.5, 2.0.4)
tzinfo-data (1.2022.1)




-- 
https://bugs.ruby-lang.org/

      parent reply	other threads:[~2022-11-13  2:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-05 20:05 [ruby-core:110627] [Ruby master Bug#19106] Time - Hour 24 with tzinfo to_s bug ruby-gregor (Greg Lindstrom)
2022-11-07  8:50 ` [ruby-core:110635] " nobu (Nobuyoshi Nakada)
2022-11-13  2:23 ` nagachika (Tomoyuki Chikanaga) [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-100066.20221113022328.52545@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    --cc=ruby-core@neon.ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).