From: tadayoshi funaba Date: 2011-06-09T08:50:27+09:00 Subject: [ruby-core:36870] [Ruby 1.9 - Bug #4460] Date.commercial date calculations don't match strftime output Issue #4460 has been updated by tadayoshi funaba. Assignee set to tadayoshi funaba ---------------------------------------- Bug #4460: Date.commercial date calculations don't match strftime output http://redmine.ruby-lang.org/issues/4460 Author: Jaap Haagmans Status: Open Priority: Normal Assignee: tadayoshi funaba Category: Target version: ruby -v: ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux] =begin When retrieving the date for a week number using Date.commercial, the output sometimes differs from what you expect when looking at strftime. In my opinion, the following should always be true: (({Date.commercial(year, week, day).strftime('%W') => week (String) })) Which is in fact true today: (({Date.today.strftime('%W') => "09" Date.commercial(2011,9,1) => Mon, 28 Feb 2011 Date.today.at_beginning_of_week => Mon, 28 Feb 2011 })) But not two years from now: (({(Date.today+2.years).strftime("%W") => "08" Date.commercial(2013,8,1) => Mon, 18 Feb 2013 (Date.today+2.years).at_beginning_of_week => Mon, 25 Feb 2013 })) so: (({Date.commercial(2013,8,1).strftime('%W') => "7"})) I'm not quite sure why this is, but I think it's a bug and unfortunately it messes up some of my date calculations. =end -- http://redmine.ruby-lang.org