Skip Menu |

This queue is for tickets about the Date-Tie CPAN distribution.

Report information
The Basics
Id: 32071
Status: resolved
Worked: 2 hours (120 min)
Priority: 0/
Queue: Date-Tie

People
Owner: FGLOCK [...] cpan.org
Requestors: sceaduw [...] gmail.com
Cc:
AdminCc:

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



Subject: week values not consistent with docs?
Hi, I seem to find that the week of the year reported for days near the end of December is not consistent with the documentation. If a week is defined as Sunday -> Saturday, (days 0 to 6), and the first week of the year is the first week with a Thursday in the new year, than I would expect Saturday, 29-Dec-2007 to be in week 52 of 2007. perl -e 'use Date::Tie; my $date = Date::Tie->new( year => 2007, month => 12, day => 29 ); print $date->{week}, "\n";' 01 Likewise, I would expect 31-Dec-2005 to be week 52 or 53, (instead of 1) as that year began on a Sunday. I may just be reading the docs incorrectly, but I ran into the problem when I defined a start time as the beginning of a week (weekday 0), for the first week of 2008, and then went back a day, I was still stuck in week 1. Thanks!
Subject: tie_context_diff
Download tie_context_diff
application/octet-stream 1k

Message body not shown because it is not plain text.

From: sceaduw [...] gmail.com
Show quoted text
> If a week is defined as Sunday -> Saturday, (days 0 to 6), and the > first week of the year is the first week with a Thursday in the > new year, than I would expect Saturday, 29-Dec-2007 to be in week > 52 of 2007.
Sorry, I got a bit confused by the day of week = 0 behavior in the array used for the end of December. The week is properly defined as a Monday -> Sunday week (days 1-7). That still doesn't explain the behavior I'm seeing; 29-Dec-2007 is still not in the first week of 2008. Thanks!
From: sceaduw [...] gmail.com
And if the week starts on a Monday, my array patch should read: 29, 32, 32, 32, 32, 31, 30, 29
The algorithm is fixed, the results now agree with DateTime.pm (see attached test file) A new version (0.18) was uploaded to CPAN thanks for reporting the bug! Note to myself: no new tests were added. - Flavio S. Glock
use DateTime; use Date::Tie; use Test::More 'no_plan'; for my $year ( 1980 .. 2030 ) { for my $month ( 1,12 ) { for my $day ( 1..31 ) { $dt = DateTime->new( year => $year, month => $month, day => $day, ); my ($week_year, $week_number) = $dt->week; #print $dt, "\n"; #print "$week_number\n"; tie my %date, 'Date::Tie', year => $year, month => $month, day => $day; #print $date{week},"\n"; ok( $date{week} == $week_number, "at $year-$month-$day $date{week} == $week_number" ); ok( $date{weekyear} == $week_year, "at $year-$month-$day $date{weekyear} == $week_year" ); } } }