Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the DateTime CPAN distribution.

Report information
The Basics
Id: 53551
Status: resolved
Priority: 0/
Queue: DateTime

People
Owner: Nobody in particular
Requestors: dmuey [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.53
Fixed in: (no value)



Subject: Jan 1 .. 3, 2010 considered week 53, week one for 2010 starts Jan 4
I've an app that sorts on week number and I noticed this problem when I saw the beginning of January was at the end of my list. DateTime seems to be miscalculating the week_number() as you can see demonstrated below. (Unless I am overlooking some nuance of week numbers?) multivac:~ dmuey$ perl -MDateTime -le 'print DateTime->VERSION;' 0.53 multivac:~ dmuey$ perl -MDateTime -le 'print DateTime->new(day=>1,month=>1,year=>2010)->week_number();' 53 multivac:~ dmuey$ perl -MDateTime -le 'print DateTime->new(day=>2,month=>1,year=>2010)->week_number();' 53 multivac:~ dmuey$ perl -MDateTime -le 'print DateTime->new(day=>3,month=>1,year=>2010)->week_number();' 53 multivac:~ dmuey$ perl -MDateTime -le 'print DateTime->new(day=>4,month=>1,year=>2010)->week_number();' 1 multivac:~ dmuey$ Other years do this too. Shouldn't January 1 be week 1?
Subject: Re: [rt.cpan.org #53551] Jan 1 .. 3, 2010 considered week 53, week one for 2010 starts Jan 4
Date: Tue, 12 Jan 2010 10:10:41 -0600 (CST)
To: Daniel Muey via RT <bug-DateTime [...] rt.cpan.org>
From: Dave Rolsky <autarch [...] urth.org>
On Sat, 9 Jan 2010, Daniel Muey via RT wrote: Show quoted text
> DateTime seems to be miscalculating the week_number() as you can see > demonstrated below. (Unless I am overlooking some nuance of week > numbers?)
From TFM: "The first week of the year is defined by ISO as the one which contains the fourth day of January, which is equivalent to saying that it's the first week to overlap the new year by at least four days." "Typically the week year will be the same as the year that the object is in, but dates at the very beginning of a calendar year often end up in the last week of the prior year, and similarly, the final few days of the year may be placed in the first week of the next year." Please don't respond directly to this ticket, as that will cause it to be re-opened. Thanks, -dave /*============================================================ http://VegGuide.org http://blog.urth.org Your guide to all that's veg House Absolute(ly Pointless) ============================================================*/
Show quoted text
> > DateTime seems to be miscalculating the week_number() as you
can see Show quoted text
> > demonstrated below. (Unless I am overlooking some nuance of
week Show quoted text
> > numbers?)
> > From TFM: > > "The first week of the year is defined by ISO as the one which contains > the fourth day of January, which is equivalent to saying that it's the > first week to overlap the new year by at least four days." > > "Typically the week year will be the same as the year that the object is > in, but dates at the very beginning of a calendar year often end up in
the Show quoted text
> last week of the prior year, and similarly, the final few days of the year > may be placed in the first week of the next year."
I see it now, thanks. That is outlined under week() I was looking at week_number() (and "week" appeared 76 times under many contexts so I stared right at it and missed it ;p). Perhaps week_year() and week_number() should say "See week() for details." since all they have is 'Returns the year of the week.' and 'Returns the week of the year, from 1..53', respectively, as the pseudo ordinality of week numbers aren't intuitive even if they are accurate. Also, what are the odds of getting a version of week_number() that is more cardinal? (i.e. week one is Jan 1 .. 7, regardless of what the fuzzy- ordinal-ish ISO week number is (week 1 vs 1st week) Just a thought, thanks! Show quoted text
> Please don't respond directly to this ticket, as that will cause it to be > re-opened.
I left the 'Status' as 'resolved (Unchanged)' in the rt menu. Hopefully that will prevent it from being re-opened :)
Subject: Re: [rt.cpan.org #53551] Jan 1 .. 3, 2010 considered week 53, week one for 2010 starts Jan 4
Date: Tue, 12 Jan 2010 10:33:06 -0600 (CST)
To: Daniel Muey via RT <bug-DateTime [...] rt.cpan.org>
From: Dave Rolsky <autarch [...] urth.org>
On Tue, 12 Jan 2010, Daniel Muey via RT wrote: Show quoted text
> Perhaps week_year() and week_number() should say "See week() for > details." since all they have is 'Returns the year of the week.' and > 'Returns the week of the year, from 1..53', respectively, as the pseudo > ordinality of week numbers aren't intuitive even if they are accurate.
Done. Show quoted text
> Also, what are the odds of getting a version of week_number() that is > more cardinal? (i.e. week one is Jan 1 .. 7, regardless of what the fuzzy- > ordinal-ish ISO week number is (week 1 vs 1st week)
But the definition of a week is Monday through Sunday, so redefining it as Jan 1-7 makes no sense. Further discussion is probably better done on the datetime@perl.org list. -dave /*============================================================ http://VegGuide.org http://blog.urth.org Your guide to all that's veg House Absolute(ly Pointless) ============================================================*/