Bug #9764
closedDate and DateTime strptime and strftime not supporting proper Week Numbering for Monday vs Sunday as start day and %G causes ignore of all other format arguments
Description
Date and DateTime strftime and strptime are not supporting %U (0-53 Week Numbers as defined in strptime):
http://www.ruby-doc.org/stdlib-2.1.1/libdoc/date/rdoc/Date.html#method-i-strftime
Some examples that are not producing expected results/output:
-
require 'date'; puts Date.new(2013,12,30).strftime("%G %U") # 2014 52 -- How is this Week 52 of 2013??
-
require 'date'; puts Date.strptime("2014 01","%G %U") # 2013-12-30 -- This should really be 2013-12-29 as the 29th is the sunday and the 30th is the Monday, and %U should be using Sunday as the first day of week.
-
The following three examples all produce the same result but really should not. Even if you change the week number to any number it still stays at the same output/result. It seems like there is a bug related to %G that ignores all other commands:
puts Date.strptime('00 2014', '%U %G') # 2013-12-30
puts Date.strptime('00 2014', '%W %G') # 2013-12-30
puts Date.strptime('2014W011', '%GW%V%u') # 2013-12-30
Additionally one would expect the following two lines to produce the same results:
puts Date.strptime('00 2014', '%W %G') # 2013-12-30
puts Date.strptime('00 2014', '%W %Y') # Invalid Date Argument