develooper Front page | perl.datetime | Postings from May 2001

Re: Grand Unified Theory of Date/Time modules

Thread Previous | Thread Next
From:
Abhijit Menon-Sen
Date:
May 5, 2001 15:05
Subject:
Re: Grand Unified Theory of Date/Time modules
Message ID:
20010506033515.A1023@lustre.linux.in
On 2001-05-05 13:09:18, rbowen@rcbowen.com wrote:
> 
> In all of the various date formats I have looked at, each one has
> certain flaws.

Have you seen the TAI64* formats at <URL:http://cr.yp.to/time.html>? (I
am supposedly writing Time::TAI64.)

> ISO requires that you know a week number, and nobody thinks like that.

ISO 8601 <URL:http://www.iso.ch/markete/8601.pdf> permits you to use
week and day numbers, but you are by no means required to do so. The
most commonly used representation looks like "CCYYMMDDTHHMMSSZ", and
there are relatively sane reduced-accuracy representations, extensions
to specify periods of time, etc.

Markus Kuhn's <http://www.cl.cam.ac.uk/~mgk25/iso-time.html> is a very
useful overview of the standard (which is unfortunately ambiguous in
several places).

> Expressing the date and the time as separate fields is too much work
> to convert back to something useful.

I'm not sure what you mean.

> And then I encountered ICal format.

ICal appears to use a subset of the ISO 8601 format (RFC 2445, sections
#4.3.{4,5,6,9,12}).

> 1) A Date::Foo object will *always* have an internal representaton as
> an ICal string, no matter what you provide it when you create it.

ICal does not permit sub-second precision, so you would lose information
when converting from formats which do. There are few practical uses for
TAI64NA's attosecond precision, but milli- and microsecond precision is
much more common in existing data.

I think ISO 8601:2000 allows fractional seconds ("SS.NN..."). Does
anyone have a copy of the standard (or want to buy me one :)?

> The consequence of this, if we're careful, is that we can create a
> Date::Discordian object, for example, and then rebless it into the
> Date::Mayan class, and it would just work:
>
> my $disco = Date::Discordian->new( disco => '23 Chaos, YOLD 3177');
> bless $disco, 'Date::Mayan';
> print $disco->mayan;

Something which avoided the re-blessing would be less fragile:

    my $disco  = Date::Discordian->new(disco => '23 Chaos, YOLD 3177');
    my $mdisco = Date::Mayan->new($disco);
    print $mdisco->as_string; # or whatever.

- ams

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About