> Have a look at DateTime::Incomplete.

it doesn't parse.
as you identify, the key question is how to get the format
modules to use it instead.

> Of course, DateTime::Format::ISO8601 still sets a default if you use it
> to 
> parse the datetime. (Joshua: You accept a DateTime object for filling in 
> missing parts; is there any chance you could also accept a 
> DateTime::Incomplete object? If such an object is supplied, your parser
> would 
> return a DT:I object)

Initial experiments suggest not:

my $basedt = DateTime::Incomplete->new(time_zone => 'floating');
my $iso8601 = DateTime::Format::ISO8601->new(base_datetime => $basedt);
my $dt = $iso8601->parse_datetime('2004');
print "has_year=", $dt->has_year(), "\n";

Use of uninitialized value in subroutine entry at
/usr/local/lib/perl5/site_perl/5.8.4/i686-linux/DateTime.pm line 393.
Use of uninitialized value in subroutine entry at
/usr/local/lib/perl5/site_perl/5.8.4/i686-linux/DateTime.pm line 394.
Can't locate object method "has_year" via package "DateTime" at test.pl
line 21.

Looking at the source code to ISO8601, it appears it has hardcoded
'DateTime' for the constructor class everywhere.

Ideally I would think this would be something to do at the Builder
level, so that more than just ISO8601 would benefit.

Or, just make the core DateTime.pm module support this feature,
obviating the need for DateTime::Incomplete....

-mda

Reply via email to