luca76 has asked for the wisdom of the Perl Monks concerning the following question:
it returns:print weeksToDays ( 1, 2013) ; (1st week of 2013)
while:31/12/2012 to 8/1/2012 (it should be ...to 6/1/2013)
it returns:print weeksToDays ( 2, 2013) ; (2nd week of 2013)
which is correct.7/1/2013 to 13/1/2013
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: big bug in Date::Calc?
by choroba (Cardinal) on Feb 19, 2013 at 11:30 UTC | |
|
Re: big bug in Date::Calc?
by tangent (Parson) on Feb 19, 2013 at 11:30 UTC | |
|
Re: big bug in Date::Calc?
by ww (Archbishop) on Feb 19, 2013 at 11:36 UTC | |
|
Re: big bug in Date::Calc?
by ww (Archbishop) on Feb 19, 2013 at 15:07 UTC | |
|
Re: big bug in Date::Calc?
by locked_user sundialsvc4 (Abbot) on Feb 19, 2013 at 13:55 UTC |