> I'm trying to figure out how to allow
> for incomplete year/month/day, year/week/day,
> or year/day in DT::I.
>
> One way is to have a separate implementation
> for each case:

Is it possible express all of these as:

If year is known:

a DateTime + a DT::Duration

If year is not known:

a null + a DT::Duration

?


> DateTime::Incomplete
>
>   year / set_year
>   month / set_month
>   day / set_day

DateTime->new( year => $y ) or a undef
DateTime::Duration( months => $m, days => $d );

>
> DateTime::Incomplete::YearWeekDay
>
>   week_year / set_week_year
>   week_number / set_week_number
>   day_of_week / set_day_of_week

DateTime->new( year => $y ) or a undef
DateTime::Duration( weeks => $w, days => $d );

> DateTime::Incomplete::YearDay
>
>   year / set_year
>   day_of_year / set_day_of_year

DateTime->new( year => $y ) or a undef
DateTime::Duration( days => $d );

This would also make to_datetime pretty simple.

> Another approach: the API would remember what
> methods were called, and adjust to that:
> if you called "set_week_number", then it is
> an error if you call "set_month".

How about checking to see if an opposing value is already set?

-J

--

Reply via email to