Subject: | Work week shifts incorrectly when 2008 starts |
Date: | Mon, 14 Jan 2008 11:51:48 -0600 |
To: | bug-DateTime-Fiscal-Year [...] rt.cpan.org |
From: | Jay Hannah <jay [...] jays.net> |
Hi Jesse --
I think I've stumbled into a bug that has thrown all my software off
for 2008. Here's one example. I wanted my work weeks to start on
Mondays, so I set up my fiscal back in 2006.
my $dt = DateTime->new(year=>2006, month=>12, day=>25);
my $fiscal = DateTime::Fiscal::Year->new( start => $dt );
All 2007 this worked great, but once 2008 rolled around,
DateTime::Fiscal::Year is incorrectly moving ALL my Mondays to the
previous work week.
Thanks for your help,
j
http://jays.net
DateTime::Fiscal::Year v0.02
perl 5.8.8
Red Hat 4.1.1-51
$ cat j.pl
use Test::More tests => 4;
use strict;
use DateTime::Fiscal::Year;
# My weeks start on Mondays
my $dt = DateTime->new(year=>2006, month=>12, day=>25);
my $fiscal = DateTime::Fiscal::Year->new( start => $dt );
my $dt2 = DateTime->new(year=>2007, month=>1, day=>7);
is($fiscal->week_of_fiscal_year( $dt2 ), 2, "First Sunday 2007");
my $dt2 = DateTime->new(year=>2007, month=>1, day=>8);
is($fiscal->week_of_fiscal_year( $dt2 ), 3, "Second Monday 2007");
my $dt2 = DateTime->new(year=>2008, month=>1, day=>6);
is($fiscal->week_of_fiscal_year( $dt2 ), 2, "First Sunday 2008");
my $dt2 = DateTime->new(year=>2008, month=>1, day=>7);
is($fiscal->week_of_fiscal_year( $dt2 ), 3, "First Monday 2008");
$ perl j.pl
1..4
ok 1 - First Sunday 2007
ok 2 - Second Monday 2007
ok 3 - First Sunday 2008
not ok 4 - First Monday 2008
# Failed test 'First Monday 2008'
# in j.pl at line 20.
# got: '2'
# expected: '3'
# Looks like you failed 1 test of 4.