Project

General

Profile

Actions

Bug #1920

closed

Date parse %U & %W

Added by delagoya (Angel Pizarro) over 14 years ago. Updated almost 13 years ago.

Status:
Rejected
Assignee:
-
ruby -v:
1.8.6p287, 1.9.1p129
[ruby-core:24851]

Description

=begin
Round trip errors for edge case dates:

Jan 01 2008

Date.strptime(Date.parse("Jan 01, 2008").strftime("%Y%U") , "%Y%U")
ArgumentError: invalid date

Dec 31, 2008

Date.strptime(Date.parse("Dec 31, 2008").strftime("%Y%W") , "%Y%W")
ArgumentError: invalid date
=end

Actions #1

Updated by nobu (Nobuyoshi Nakada) over 14 years ago

=begin
Hi,

At Tue, 11 Aug 2009 00:47:44 +0900,
Angel Pizarro wrote in [ruby-core:24851]:

Round trip errors for edge case dates:

Jan 01 2008

Date.strptime(Date.parse("Jan 01, 2008").strftime("%Y%U") , "%Y%U")
ArgumentError: invalid date

Dec 31, 2008

Date.strptime(Date.parse("Dec 31, 2008").strftime("%Y%W") , "%Y%W")
ArgumentError: invalid date

%U and %W mean week numbers, so the results, "200800" and
"200852" don't have enough info to determine their date.
You need to include %w together.

$ ruby -rdate -e 'p Date.strptime(Date.parse("Jan 01, 2008").strftime("%Y%U%w") , "%Y%U%w")'
#<Date: 2008-01-01 (4908933/2,0,2299161)>

$ ruby -rdate -e 'p Date.strptime(Date.parse("Dec 31, 2008").strftime("%Y%W%w") , "%Y%W%w")'
#<Date: 2008-12-31 (4909663/2,0,2299161)>

--
Nobu Nakada

=end

Actions #2

Updated by nobu (Nobuyoshi Nakada) over 14 years ago

  • Status changed from Open to Rejected

=begin

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0