I'd like to use DateTime object from within the Template-Toolkit, so I hacked this up. Feedback welcome.
(I'm a TT newbie, so please let me know if I seem to be doing something wrong) =head1 NAME Template::Plugin::DateTime - A Template Plugin To Use DateTime Objects =head1 SYNOPSIS [% USE date = DateTime(year = 2004, month = 4, day = 1) %] [% USE date = DateTime(today = 1) %] Today is [% date.year %]/[% date.month %]/[% date.day %]. [% date.add(days => 32) %] 32 days from today is [% date.year %]/[% date.month %]/[% date.day %]. =head1 DESCRIPTION The basic idea to use a DateTime plugin is as follows: US date = DateTime(year = 2004, month = 4, day = 1); But you cann pass optional parameters to the constructor to create a DateTime object using the other DateTime constructors: =over 4 =item from_epoch Creates a Datetime object by calling DateTime::from_epoch(). The value for the from_epoch parameter must be a number representing UNIX epoch. [% epoch = ... %] [% USE date = DateTime(from_epoch = epoch) %] =item now Creates a DateTime object by calling DateTime::now(). The value for the c<now> parameter is a boolean value. [% USE date = DateTime(now = 1) %] [% USE date = Datetime(now = 1, time_zone => 'Asia/Tokyo') %] =item today Creates a DateTime object by calling DateTime::today(). The value for the c<today> parameter is a boolean value. [% USE date = DateTime(today = 1) %] =item from_object Creates a DateTime object by calling DateTime::from_object(). The value for the from_object must be an object implementing the utc_rd_values() method, as described in DateTime.pm [% USE date = DateTime(from_object = other_date) %] =item last_day_of_month Creates a DateTime object by calling DateTime::last_day_of_month(). The value for the c<last_day_of_month> parameter is a boolean value, and C<year> and C<month> parameters must be specified. [% USE date = DateTime(last_day_of_month = 1, year = 2004, month = 4 ) %] =back =head1 SEE ALSO L<DateTime> L<Template> =head1 AUTHOR Copyright 2004 Daisuke Maki E<gt>[EMAIL PROTECTED]<lt>. All rights reserved. =cut
