[EMAIL PROTECTED] (Eugene Van Der Pijll) wrote:
> Peter J. Acklam schreef:
>
> > The code
> >
> > my $dt = DateTime->new( year => -7 );
> > print $dt->iso8601(), "\n";
> >
> > prints
> >
> > -006-01-01T00:00:00
> >
> > but ISO 8601 requires at least four digits in the year.
>
> No. I haven't read ISO 8601, but you claimed it was defined for
> the range [0000,9999]. The above date falls outside of this
> range, and the proper output of iso8601() is unspecified.
ISO 8601 includes an expanded format which allows years outside of
the range [0000,9999]. However, this expanded format should not
be used unless it has been agreed upon by all parties involved.
If iso8601() does not allow years outside [0000,9999], then it
should return undef() rather than some non-ISO 8601 format, I think.
> Of course, it might be a good idea to change the format for BC
> years. But it's not required by ISO 8601.
I'm afraid you're wrong. ISO 8601 requires that a year is
formatted with at least four digits (except when the century is
implied, then two is sufficient). By the way, how do you know
what the standard requires if you haven't read it? ;-)
> On your other point: I think it would be nice if DateTime::new
> would accept years like '1974AD', '44BC, '2003CE' and '753BCE'.
> But most people would say the year -753 meant 753 BC, so I would
> keep that definition.
This implies that someone converting from an ISO 8601 format must
subtract one from the year if year <= 0 before feeding the value
into the DateTime constructor.
> But should new() know what to do when it receives the year
> '1381AH'? '2756AUC'? '29BP'? '26 anno regni regis Iulianae'?
First of all, the year input to the constructor must be a year in
the Gregorian calendar. Secondly, adding one format ("BC" or
whatever) doesn't imply that one must add everything under the
sun.
Peter
--
#!/local/bin/perl5 -wp -*- mode: cperl; coding: iso-8859-1; -*-
# matlab comment stripper (strips comments from Matlab m-files)
s/^((?:(?:[])}\w.]'+|[^'%])+|'[^'\n]*(?:''[^'\n]*)*')*).*/$1/x;