On Wed, 12 Feb 2003, Dave Rolsky wrote:

> The problem is that in the future there may be format modules for which
> parameters need to be set on a per-object basis.  For example, a "human
> language" parser might take an argument to set the language.
>

That is hardly the only thing OO gets us.  It seems obvious that a Format
would be an object, so that I can have code which parses and display a
date without knowing what kind of date it is.

Also, I think it would be cool if we made DateTime::stftime()
DateTime::Format aware, e.g.:

sub strftime {
....
    foreach my $f (@formats) {
        if ( ref($f) and UNIVERSAL::isa($f, 'DateTime::Format') ) {
           if ( $self->isa('DateTime::Duration') ) {
               push @r, $f->format_duration( $self );
           }
           else {
               push @r, $f->format_datetime( $self );
           }
        }
        else {
....

}

This presumes a base DateTime::Format class, but that was only a matter of
time, and presumably its an 'abstract' class.

What do you think?  Good idea?  (that code was written inline, and is just
for demo purposes)

Another option is to have a DateTime->format() method that can dispatch to
a Format object, or strftime, and leave strftime alone.

> Yes, the object for the iCal format is pointless, but I'd like to have the
> same(-ish) API for all format modules.

And its really not pointless.  So its all good.

kellan

-- 
"the truth is always revolutionary" [antonio gramsci]

[EMAIL PROTECTED]

Reply via email to