ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:93557] [Ruby master Bug#15988] Time#dst? vs "real" timezones
       [not found] <redmine.issue-15988.20190705090036@ruby-lang.org>
@ 2019-07-05  9:00 ` zverok.offline
  2019-07-05 12:09 ` [ruby-core:93558] " zverok.offline
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 4+ messages in thread
From: zverok.offline @ 2019-07-05  9:00 UTC (permalink / raw
  To: ruby-core

Issue #15988 has been reported by zverok (Victor Shepelev).

----------------------------------------
Bug #15988: Time#dst? vs "real" timezones
https://bugs.ruby-lang.org/issues/15988

* Author: zverok (Victor Shepelev)
* Status: Open
* Priority: Normal
* Assignee: 
* 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
```



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

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

* [ruby-core:93558] [Ruby master Bug#15988] Time#dst? vs "real" timezones
       [not found] <redmine.issue-15988.20190705090036@ruby-lang.org>
  2019-07-05  9:00 ` [ruby-core:93557] [Ruby master Bug#15988] Time#dst? vs "real" timezones zverok.offline
@ 2019-07-05 12:09 ` zverok.offline
  2019-07-05 20:59 ` [ruby-core:93565] " merch-redmine
  2019-07-06  3:56 ` [ruby-core:93575] " nobu
  3 siblings, 0 replies; 4+ messages in thread
From: zverok.offline @ 2019-07-05 12:09 UTC (permalink / raw
  To: ruby-core

Issue #15988 has been updated by zverok (Victor Shepelev).


Even funnier:
```ruby
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!
(winter + 1).dst?                             # => false -- fixed!
```

----------------------------------------
Bug #15988: Time#dst? vs "real" timezones
https://bugs.ruby-lang.org/issues/15988#change-79127

* Author: zverok (Victor Shepelev)
* Status: Open
* Priority: Normal
* Assignee: 
* 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
```



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

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

* [ruby-core:93565] [Ruby master Bug#15988] Time#dst? vs "real" timezones
       [not found] <redmine.issue-15988.20190705090036@ruby-lang.org>
  2019-07-05  9:00 ` [ruby-core:93557] [Ruby master Bug#15988] Time#dst? vs "real" timezones zverok.offline
  2019-07-05 12:09 ` [ruby-core:93558] " zverok.offline
@ 2019-07-05 20:59 ` merch-redmine
  2019-07-06  3:56 ` [ruby-core:93575] " nobu
  3 siblings, 0 replies; 4+ messages in thread
From: merch-redmine @ 2019-07-05 20:59 UTC (permalink / raw
  To: ruby-core

Issue #15988 has been updated by jeremyevans0 (Jeremy Evans).

Assignee set to nobu (Nobuyoshi Nakada)
Status changed from Open to Assigned
File time-zone-dst.patch added

The behavior seems even worse in the master branch and 2.7.0-preview1, with a RuntimeError without a calculation, and always false after a calculation:

```ruby
require 'tzinfo'
z = TZInfo::Timezone.get('Europe/Kiev')
t = Time.new(2019, 6, 1, 14, 30, 12, z)
t.dst?
# RuntimeError (isdst is not set yet)
(t + 1).dst?
# false
(t + 6 * 30 * 24 * 60 * 60).dst?
# false
```

Attached is a patch that calls `dst?` on the timezone object to determine whether the time is in daylight savings time in the zone.  This does add a method called on the timezone argument, though, so I'm not sure how acceptable it is.  Both the tzinfo and timezone libraries appear to implement the method already. 

----------------------------------------
Bug #15988: Time#dst? vs "real" timezones
https://bugs.ruby-lang.org/issues/15988#change-79135

* 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/

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

* [ruby-core:93575] [Ruby master Bug#15988] Time#dst? vs "real" timezones
       [not found] <redmine.issue-15988.20190705090036@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2019-07-05 20:59 ` [ruby-core:93565] " merch-redmine
@ 2019-07-06  3:56 ` nobu
  3 siblings, 0 replies; 4+ messages in thread
From: nobu @ 2019-07-06  3:56 UTC (permalink / raw
  To: ruby-core

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/

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

end of thread, other threads:[~2019-07-06  3:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <redmine.issue-15988.20190705090036@ruby-lang.org>
2019-07-05  9:00 ` [ruby-core:93557] [Ruby master Bug#15988] Time#dst? vs "real" timezones zverok.offline
2019-07-05 12:09 ` [ruby-core:93558] " zverok.offline
2019-07-05 20:59 ` [ruby-core:93565] " merch-redmine
2019-07-06  3:56 ` [ruby-core:93575] " nobu

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