Daisuke Maki wrote:
I actually would rather see an mod_perl-style 'add if requested' style.
use DateTime; # load just the basics
use DateTime::Format qw(strftime strptime hms);
# maybe use DateTime::Format qw(:common) ?
my $dt = DateTime->now;
print $dtd->hms;
At least, I don't much like the idea of having to use a different class
name like 'DTD'
I'm cool with that .. I guess then that each Format module that is
'use'd would somehow publish methods to the DateTime Class rather than
an object? I'm not sure how this would be technically done using your
example code ..
I guess we could get DateTime to suck in decorators or formats?
use DateTime qw(
DateTime::Format::Strftime
DateTime::Format::Common
);
Each Format module would then be checked for a %DECORATORS hash of
coderefs which would become methods in DateTime:
package DateTime::Format::Strptime;
.. current code base doesn't change ..
use vars qw/%DECORATORS/;
%DECORATORS = (
strptime => sub {
my $self = shift; # This is a DT object
my $pattern = shift;
my $string = shift;
my $formatter = DateTime::Format::Strptime->new(
pattern => $pattern
)
$self = $formatter->parse_datetime( $string );
}
);