ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:110627] [Ruby master Bug#19106] Time - Hour 24 with tzinfo to_s bug
@ 2022-11-05 20:05 ruby-gregor (Greg Lindstrom)
  2022-11-07  8:50 ` [ruby-core:110635] " nobu (Nobuyoshi Nakada)
  2022-11-13  2:23 ` [ruby-core:110731] " nagachika (Tomoyuki Chikanaga)
  0 siblings, 2 replies; 3+ messages in thread
From: ruby-gregor (Greg Lindstrom) @ 2022-11-05 20:05 UTC (permalink / raw)
  To: ruby-core

Issue #19106 has been reported by ruby-gregor (Greg Lindstrom).

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

* Author: ruby-gregor (Greg Lindstrom)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x64-mingw-ucrt]
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
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/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ruby-core:110635] [Ruby master Bug#19106] Time - Hour 24 with tzinfo to_s bug
  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 ` nobu (Nobuyoshi Nakada)
  2022-11-13  2:23 ` [ruby-core:110731] " nagachika (Tomoyuki Chikanaga)
  1 sibling, 0 replies; 3+ messages in thread
From: nobu (Nobuyoshi Nakada) @ 2022-11-07  8:50 UTC (permalink / raw)
  To: ruby-core

Issue #19106 has been updated by nobu (Nobuyoshi Nakada).


https://github.com/ruby/ruby/pull/6682

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

* Author: ruby-gregor (Greg Lindstrom)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x64-mingw-ucrt]
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
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/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ruby-core:110731] [Ruby master Bug#19106] Time - Hour 24 with tzinfo to_s bug
  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)
  1 sibling, 0 replies; 3+ messages in thread
From: nagachika (Tomoyuki Chikanaga) @ 2022-11-13  2:23 UTC (permalink / raw)
  To: ruby-core

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/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-11-13  2:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [ruby-core:110731] " nagachika (Tomoyuki Chikanaga)

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).