[ruby-core:93575] [Ruby master Bug#15988] Time#dst? vs "real" timezones
From:
nobu@...
Date:
2019-07-06 03:56:50 UTC
List:
ruby-core #93575
Issue #15988 has been updated by nobu (Nobuyoshi Nakada).
I've noticed it and have a patch, but haven't committed it yet as not written the test using dummy timezone objects.
----------------------------------------
Bug #15988: Time#dst? vs "real" timezones
https://bugs.ruby-lang.org/issues/15988#change-79155
* Author: zverok (Victor Shepelev)
* Status: Assigned
* Priority: Normal
* Assignee: nobu (Nobuyoshi Nakada)
* Target version:
* ruby -v: 2.6.3
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
My current timezone is Europe/Kiev.
With default zone (how it was previously):
```ruby
summer = Time.new(2019, 6, 1, 14, 30, 12) # => 2019-06-01 14:30:12 +0300
summer.zone # => "EEST"
summer.dst? # => true
winter = Time.new(2019, 12, 1, 14, 30, 12) # => 2019-12-01 14:30:12 +0200
winter.zone # => "EET"
winter.dst? # => false
```
(Note it is correctly `true` in summer and `false` in winter.)
With "real" timezone object
```ruby
require 'tzinfo'
z = TZInfo::Timezone.get('Europe/Kiev')
# => #<TZInfo::DataTimezone: Europe/Kiev>
summer = Time.new(2019, 6, 1, 14, 30, 12, z) # => 2019-06-01 14:30:12 +0300
summer.zone # => #<TZInfo::DataTimezone: Europe/Kiev>
summer.dst? # => true
winter = Time.new(2019, 12, 1, 14, 30, 12, z) # => 2019-12-01 14:30:12 +0200 -- offset is correct
winter.zone # => #<TZInfo::DataTimezone: Europe/Kiev>
winter.dst? # => true -- this is wrong!
```
Note that offsets are calculated correctly (+3 in summer, +2 in winter), but `dst?` is always `true`.
TZInfo itself calculates DST properly:
```ruby
z.dst?(summer) # => true
z.dst?(winter) # => false
```
Seems like a serious bug to me (or at least very hard to explain behavior).
PS: With arithmetics, everything works correctly:
```ruby
six_months = 6 * 30 * 24 * 60 * 60
summer + six_months # => 2019-11-28 13:30:12 +0200
(summer + six_months).dst? # => false -- that is correct
```
---Files--------------------------------
time-zone-dst.patch (1.68 KB)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>