On Fri, 24 Jan 2003, Clayton L. Scott wrote:

> So if I want to use Sunday as the first day of the week every will
> method I use will have "sunday" in it? What if for some business reason
> I decide that it's easier to do my calculations if Wednesday is the first
> day of the week?
>
> How about:
>
> use DateTime;
> use DateTime::Lingua::EN;
> use DateTime::Lingua::FR;
>
> DateTime::first_day_of_week( DateTime::Lingua::EN::SUNDAY );
>
> or maybe we can make english the "blessed default language like we are
> doing for the Gragorian Calendar"
>
> DateTime::first_day_of_week( SUNDAY ); # Exported Constant?
>
> DateTime::first_day_of_week( DateTime::Lingua::EN::DIMANCHE );

This is not going to happen.  Allowing this sort of thing makes it
impossible for a module to trust a DateTime object that it's given.  The
API needs to be fixed, so that day_of_week _always_ means the same thing.

And if you _really_ want to treat Wednesday as day 1, you can do this.

 sub day_of_week_wednesday_first
 {
     my $dt = shift;
     my $dow = $dt->day_of_week; # monday first
     $dow = ( ( $dow + 7 ) - 2 ) % 7 );

     return $dow;
 }

> > >    3) How many days of a week must be in the new year before
> > >       the week is considered the first week in the new year?
> > >       (ISO: 4, US: 1 and 7)
> >
>
> > Eek, I'm not sure I want to touch this yet.  But if people have good mehod
> > names, I'm happy to include it.
>
> DateTime::min_days_first_week_of_year(7)
>
> If it's a Class value and is object overridable ...

Again, for the same reasoning as above, this is not going to happen.

Module authors need to be able to say "given a DateTime object,
function/method X returns Y", without having to set class variables of its
own (and then who wins?)


-dave

/*=======================
House Absolute Consulting
www.houseabsolute.com
=======================*/

Reply via email to