Ben Bennett wrote:
>
> What were your thoughts on the constructor? I think people expect a
> new, but are unspecified things 0 (like DateTime) or undefined?
new() could be just like DateTime->new,
while whatever() defaults to xxxx-xx-xxTxx:xx:xx
> Also, what happens when you compare dates (or is that simply not
> defined?).
It would compare dates in the form defined-defined-undef-undef,
but it can't compare dates like undef-undef-defined-defined.
Well, maybe it can. If 2 dates have the same fields defined, for
example.
> Now that I think about it, you will probably need contains,
> intersects, etc. But I assume you already planned that.
Yep.
> For the name, my thoughts are:
> DT::Partial
> DT::Incomplete
> DT::Reduced
Whatever :)
'Incomplete' is the funniest.
> Is it useful to have an optional base DT that can be used when an item
> is undefined (to more easily allow Time only objects):
> --
> my $dtw = DateTime::Whatever->new
> (hour => 10, minute => 5, second => 2);
> my $dt = DateTime->new(year => 2003, month => 7, day => 18);
>
> $dtw->set( base => $dt );
>
> print $dtw->year; # 2003
> --
ok.
> If you do that it may also be useful to have a method fix() (or
> get_datetime() or flatten() or something) that returns a DateTime
> either using the current base datetime, a provided datetime, or now()
> (perhaps today()). This would make it convenient as a the thing to
> return from formats where there can be missing information:
> --
> ...
> my $dt = DateTime::Format::Whatever->parse_datetime("12:30")
> ->flatten();
> ...
> --
ok. This would be achieved with
$dtw->next( DT->today ) # flatten_day()
$dtw->next( DT->now ) # flatten()
and the inverse operation:
$dtw->set( year=>undef, month=>undef, day=>undef) # time()
> Or am I off my rocker?
me too?
- Flavio S. Glock
> On Fri, Jul 18, 2003 at 12:54:55PM -0300, Flavio S. Glock wrote:
> > Yes, this is better:
> >
> > $dtc1->set( month => 12 );
> > $dtc1->set( month => undef );
> >
> > It can work without cloning, in order to be compatible with DateTime
> > API.
> >
> > Name - how about DateTime::Whatever ? (I like it)
> >
> > $date = DateTime::Whatever->whatever( year => 2003 );
> > # 2003-xx-xxTxx:xx:xx
> >
> > $date = DateTime::Whatever->new( year => 2003, day => undef )
> > # 2003-xx-01-T00:00:00
> >
> > And this is one of the lines I snipped from the previous mail:
> >
> > $date->add( months => 12 )
> > # 2004-xx-01-T00:00:00
> >
> > - Flavio S. Glock
> >
> >
> > Ben Bennett wrote:
> > >
> > > I like the idea (this is the partial date & time thing right?) but I
> > > am not too sure about the name... unless you start dealing with times
> > > with real and imaginary parts :-) (Not that I have any suggestions for
> > > a name yet).
> > >
> > > Regarding the interface would it be better to have:
> > > --
> > > my $dtc1 = DateTime::Complex->new_undef();
> > > # I assume that DT::C->new() assumes 0 like DT->new()
> > > # but that DT::C->new(year => 2003, day => undef )
> > > # would give 2003-xx-01-T00:00:00?
> > >
> > > my $dtc2 = $dtc1->set( month => 12 );
> > > my $christmas = $dtc2->set( day => 24 );
> > > # Do these clone BTW or are $dtc1, $dtc2 and $christmas all refs
> > > # to the same object (like DateTime does)?
> > >
> > > my $december = $christmas->set(day => undef);
> > >
> > > print $december->datetime;
> > > # xxxx-12-xxTxx:xx:xx
> > >
> > > # See above question re cloning objects.
> > > print $christmas->next( DateTime->now )->datetime;
> > > # 2003-12-24Txx:xx:xx
> > >
> > > my $xmas_noon = $christmas->clone()->set( hour => 12 );
> > >
> > > print $christmas->contains( $xmas_noon );
> > > # 1
> > > --
> > >
> > > Regarding the cloning question, it is more like DateTime if they do
> > > not get cloned autmomatically, but I am assuming your implementation
> > > is based on your DT::Set which I think does clone automatically? I
> > > would still vote for not cloning.