I saw that mail, but I meant yet another constructor that will take an
ISO week number and day number (within the week) and a "year"
construct the appropriate date.

Note that the year given may not be the actual year the date falls in
but is rather the ISO year number.  (For instance day 1 of week 1 of
2003 is 2002-12-30!)

You can manaully do this by doing:
--
my $dt = DateTime->new(year => $year, month => 1, day => 4);
my $adjustment = 
   ( ($week_num - 1) * 7   ) + 
   (  $day_num - 1         ) -
   (  $dt->day_of_week - 1 );
$dt->add($adjustment);
--

                          -ben


On Fri, Jun 20, 2003 at 05:08:09PM -1000, Joshua Hoblitt wrote:
> On Fri, 20 Jun 2003, Ben Bennett wrote:
> 
> > Is this for taking an ISO week number and day of week and getting a
> > month, day and year back?
> >
> > Dave, would it be possible to have a DT constructor for this?  There
> > is an accessor (week()) that does the reverse...  For the ISO8601
> > module it would be nice to have this, although it is easy enough to do
> > by hand.
> 
> I still think there might be a need for DT::Util but for this case (I was thinking 
> of ISO8601 as well) there is another constructor.
> 
> To quote Dave:
> 
> Date: Fri, 20 Jun 2003 16:09:42 -0500 (CDT)                                          
>                                              From: Dave Rolsky <[EMAIL PROTECTED]>   
>                                                                                      
>       To: Ben Bennett <[EMAIL PROTECTED]>                                            
>                                                  Cc: Rick Measham <[EMAIL 
> PROTECTED]>, "Hill, Ronald" <[EMAIL PROTECTED]>, "'[EMAIL PROTECTED]'" <[EMAIL 
> PROTECTED]>  Subject: Re: Having problems with Datetime-format-Strptime-1.02 install 
>  on Wi n32                                                                           
>                                                                                      
>                   On Fri, 20 Jun 2003, Ben Bennett wrote:                            
>                                                                                      
>                                                                                      
>                        > Personally I think this is a good reason to either add a 
> new                                                                    > DateTime 
> constructor or to add the flag that relaxes the parameter                            
>                                   > validation and allows rollovers.                 
>                                                                                      
>                                                                                      
>                                        There is a DateTime->from_day_of_year 
> constructor.                                                                         
>                                                                                      
>                                                                                      
>                                                                                      
>             -dave                                                                    
>                                                                                      
>                                                                                      
>                  /*=======================                                           
>                                                               House Absolute 
> Consulting                                                                           
>                               www.houseabsolute.com                                  
>                                                                            
> =======================*/
> 

Reply via email to