This may have passed under people's radars a couple of weeks ago so here it is again. This is an RFC release of DateTime::Decorated and a couple of 'Decorations'.

I'm hoping that I'm not the only one interested in this and so can get a couple of other people's feedback, Dave's in particular as it requires his Class::ClassDecorator in order to function.

Below is a brief view of how to use it (a synopsis)

Please let me know what you think .. comments, criticism, whatever! Anything but deafening silence :)

Dave: Would love to see your C:CD module allow a name for the decorated class. When it isn't provided, then generate your unique name. I'm not sure how robust my method will be :)

Cheers!
Rick Measham



use DateTime::Decorated
    with => [ 'OrderedMath', 'ISO8601' ],
    as   => 'Decorated';

#or with => [ 'DateTime::Decorated::OrderedMath',
#             'DateTime::Decorated::ISO8601' ],
# When there's colons it first tries to use a module with that name, if
# that fails it adds 'DateTime::Decorated::' to the front and tries
# again. If there's no colons, it first tries to add the prefix and if
# that fails, it tries loading just the name.


# We now have a 'Decorated' class that we can use
my $dt = Decorated->today;

# The class is DateTime, decorated with a couple of decorations that
# include a 'parse' routine for parsing ISO datetimes.
my $dt2 = Decorated->parse( $dt->datetime );


# And is also knows about LSB/MSB math ..
my $now = Decorated->now();

my $dur = $now - $dt1;

print $dt2->add_lsb( $dur )->datetime;

print $dt2->add_msb( $dur )->datetime;

__END__



Reply via email to