Project

General

Profile

Bug #17024

Times with timezones return incorrect wday and yday

Added by timcraft (Tim Craft) 29 days ago. Updated 17 days ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.8.0dev
[ruby-core:99127]

Description

The timezone support added to Time in Ruby 2.6 does not appear to handle wday and yday.

I don't know what the most appropriate fix is, but looking at time.c and the commit which introduced the timezone feature it looks like vtm->wday and vtm->yday are both set by vtm_add_offset, and that isn't called with the new block of code which handles the timezone.

I've attached a patch to the tests and specs which demonstrates the bug.


Files

patch.diff (1.03 KB) patch.diff timcraft (Tim Craft), 07/11/2020 10:19 AM

Updated by timcraft (Tim Craft) 29 days ago

For example:

$ irb -r tzinfo
irb(main):001:0> Time.new(2020, 1, 1, 0, 0, 0, TZInfo::Timezone.get('America/New_York')).wday
=> 7
irb(main):002:0> Time.new(2020, 1, 1, 0, 0, 0, TZInfo::Timezone.get('America/New_York')).yday
=> 0

(The wday should be 3, and the yday should be 1.)

Updated by nobu (Nobuyoshi Nakada) 28 days ago

  • Backport changed from 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN to 2.5: DONTNEED, 2.6: REQUIRED, 2.7: REQUIRED
#3

Updated by nobu (Nobuyoshi Nakada) 28 days ago

  • Status changed from Open to Closed

Applied in changeset git|99a9c3fe2eaab8157765d792dc871da6daea0327.


Fixed yday and wday with timezone [Bug #17024]

Updated by nagachika (Tomoyuki Chikanaga) 17 days ago

  • Backport changed from 2.5: DONTNEED, 2.6: REQUIRED, 2.7: REQUIRED to 2.5: DONTNEED, 2.6: REQUIRED, 2.7: DONE

ruby_2_7 4be9bf1f67b997fc519625d56a93b8a68a70d124 merged revision(s) 99a9c3fe2eaab8157765d792dc871da6daea0327.

Also available in: Atom PDF