[cc'ing back to the list]
On Fri, 16 Dec 2005, Tatsuhiko Miyagawa wrote:
Sorry for the dumb question.
Suppose I have $year == 2005 and $week_number == 42, how can I get the
date range (or first day) of the week number, in DateTime?
There's no really nice way to do this right now, though you can do it
programatically:
my $dt = DateTime->new( year => $year );
my ($week_year, $week_num) = $dt->week();
until ( $week_year == $year && $week_num = $week_i_want ) {
$dt->add( days => 1 );
($week_year, $week_num) = $dt->week();
}
This seems like something that'd be a nice add-on constructor for
DateTime.pm. Maybe we need some DateTime::Constructor::* modules or
something, because I sure don't want dozens of constructors in the core
code.
If you look in DateTime.pm at the week() sub you'll see how that's
calculated. Some clever person could probably reverse the algorithm to
make a constructor.
-dave
/*===================================================
VegGuide.Org www.BookIRead.com
Your guide to all that's veg. My book blog
===================================================*/