Skip Menu |

This queue is for tickets about the TimeDate CPAN distribution.

Report information
The Basics
Id: 40029
Status: resolved
Priority: 0/
Queue: TimeDate

People
Owner: Nobody in particular
Requestors: dougie.lawson [...] ukonline.co.uk
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.16
Fixed in: (no value)



Subject: Week Number is incorrect
I was using the following code use Date::Format; my $week = time2str("%W",time); That gives a result on 13th Oct 2008 of week 41. Which is incorrect. The current week number is 42.
Subject: Re: [rt.cpan.org #40029] Week Number is incorrect
Date: Tue, 14 Oct 2008 08:26:07 -0500
To: bug-TimeDate [...] rt.cpan.org
From: Graham Barr <gbarr [...] pobox.com>
On Oct 14, 2008, at 3:04 AM, Dougie Lawson via RT wrote: Show quoted text
> I was using the following code > > use Date::Format; > my $week = time2str("%W",time); > > That gives a result on 13th Oct 2008 of week 41. Which is incorrect. > The > current week number is 42.
No, it is 41. weeks are counted in the year to which they start. Jan 1 2008 was a Tuesday and weeks are counted starting on Monday, so week 1 started on Jan 7. The C library agrees with Date::Format $ perl -MPOSIX=strftime -le '$x=time-86400; print scalar localtime($x),"\n",strftime("%W",localtime($x))' Mon Oct 13 08:23:55 2008 41 Graham.
From: dougie.lawson [...] ukonline.co.uk
On Tue Oct 14 09:26:34 2008, gbarr@pobox.com wrote: Show quoted text
> > No, it is 41. weeks are counted in the year to which they start. Jan 1 > 2008 was a Tuesday and weeks are counted starting on Monday, so week 1 > started on Jan 7. > > The C library agrees with Date::Format > > $ perl -MPOSIX=strftime -le '$x=time-86400; print scalar > localtime($x),"\n",strftime("%W",localtime($x))' > Mon Oct 13 08:23:55 2008 > 41 > > Graham.
So why does that disagree with IBM's Lotus Notes calender, PHP's date('W') and the result from another perl module Date::Calc? All those give this week (starting Monday) as week 42. It also disagrees with http://en.wikipedia.org/wiki/ISO_week_date Is it a count from zero vs count from one issue? I've switched to use Date::Calc (which is cumbersome). I liked time2str(...) as it's a whole lot easier to use. Rgds, Dougie.