On Mon, 31 Jan 2005 [EMAIL PROTECTED] wrote:
Besides the common units, it can calculate 'year_weekly' and 'month_weekly' (week of year, week of month).
DT already supports both of these, doesn't it? Check out the week(), week_year(), week_number(), and week_of_month() methods.
The subroutine accepts an iCal specification to select the week algorithm. It defaults to the ISO recommendation (week_start_day => 'mo').
$year = as_number( $today, unit => 'year_weekly', week_start_day => '1su' );
This might be worth adding to DT itself, except I think I'd prefer to have the value of "week_start_day" be a number from 1-7.
truncate( $datetime, to => 'year' )
Just like the DateTime->truncate method, but this one can accept 'year_weekly' and 'month_weekly' parameters, and an optional 'week_start_day'.
This also might be good for the core.
round_up( $datetime, to => 'year' )
Just like "truncate", but it rounds up. This is roughly the same as
truncate( $dt, to => 'year' )->add( years => 1 )
except that it also works with 'year_weekly' and 'month_weekly' parameters.
Same with this.
-dave
/*=================================================== VegGuide.Org www.BookIRead.com Your guide to all that's veg. My book blog ===================================================*/