http://www.perlmonks.org?node_id=1019521

luca76 has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I think I've found a bug in Date::Calc with add_delta_days function. I get a week number and a year in my function and I want to calculate the date starting and ending that week. To calculate it, I use supplied Monday_of_week (first day), then I add 6 days to it to get the Sunday. Trying this function with:
print weeksToDays ( 1, 2013) ; (1st week of 2013)
it returns:
31/12/2012 to 8/1/2012 (it should be ...to 6/1/2013)
while:
print weeksToDays ( 2, 2013) ; (2nd week of 2013)
it returns:
7/1/2013 to 13/1/2013
which is correct.
use Date::Calc qw ( Monday_of_Week Add_Delta_Days ); sub weekToDays { $week = shift; $year = shift; ($year,$month,$day) = Monday_of_Week($week,$year); ($y, $m, $d) = Add_Delta_Days( Monday_of_Week( $week, $year ), 6); return "$day/$month/$year to $d/$m/$y"; } print "First week of 2013: ".weekToDays ( 1, 2013) ."\n" ; print "Second week of 2013: ".weekToDays ( 2, 2013) ."\n" ;

Update: Thank you to all. One word: I'm a dumb idiot :D