Template-Plugin-DateTime-0.06002/000755 000765 000024 00000000000 11616375652 017166 5ustar00daisukestaff000000 000000 Template-Plugin-DateTime-0.06002/Changes000644 000765 000024 00000001166 11616375557 020471 0ustar00daisukestaff000000 000000 Changes ======= 0.06002 - 04 Aug 2011 - Fix rt#70001, 5.14 deprecations. - Moved to github 0.06001 - 31 Aug 2008 - ??? 0.06000 - 31 Aug 2008 - Apply Jeff Lanza's patch, and add a from_string mode, where it makes it possible to create a DateTime object from a string. 0.05 - 29 May 2007 - Migrate to Module::Install 0.04 - Never Released - No code change. - Add POD tests. 0.03 - 28 Aug 2005 - Very slight modification to work better with Devel::Cover 0.02 - 11 Jan 2004 - Actually add it to datetime CVS - minor house cleaning - use traditional Makefile.PL 0.01 - 03 Apr 2004 - Initial releaseTemplate-Plugin-DateTime-0.06002/inc/000755 000765 000024 00000000000 11616375652 017737 5ustar00daisukestaff000000 000000 Template-Plugin-DateTime-0.06002/lib/000755 000765 000024 00000000000 11616375652 017734 5ustar00daisukestaff000000 000000 Template-Plugin-DateTime-0.06002/Makefile.PL000644 000765 000024 00000000337 11616374773 021146 0ustar00daisukestaff000000 000000 use strict; use inc::Module::Install; name('Template-Plugin-DateTime'); all_from('lib/Template/Plugin/DateTime.pm'); requires 'DateTime'; requires 'Template'; requires 'DateTime::Format::Strptime'; auto_include; WriteAll;Template-Plugin-DateTime-0.06002/MANIFEST000644 000765 000024 00000000606 11616375374 020322 0ustar00daisukestaff000000 000000 Changes inc/Module/Install.pm inc/Module/Install/Base.pm inc/Module/Install/Can.pm inc/Module/Install/Fetch.pm inc/Module/Install/Include.pm inc/Module/Install/Makefile.pm inc/Module/Install/Metadata.pm inc/Module/Install/Win32.pm inc/Module/Install/WriteAll.pm lib/Template/Plugin/DateTime.pm Makefile.PL MANIFEST This list of files META.yml t/01-sanity.t t/99_pod-coverage.t t/99_pod.t Template-Plugin-DateTime-0.06002/META.yml000644 000765 000024 00000001142 11616375645 020437 0ustar00daisukestaff000000 000000 --- abstract: 'A Template Plugin To Use DateTime Objects' author: - 'Copyright (c) 2004-2007 Daisuke Maki .' build_requires: ExtUtils::MakeMaker: 6.42 configure_requires: ExtUtils::MakeMaker: 6.42 distribution_type: module generated_by: 'Module::Install version 1.01' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Template-Plugin-DateTime no_index: directory: - inc - t requires: DateTime: 0 DateTime::Format::Strptime: 0 Template: 0 resources: license: http://dev.perl.org/licenses/ version: 0.06002 Template-Plugin-DateTime-0.06002/t/000755 000765 000024 00000000000 11616375652 017431 5ustar00daisukestaff000000 000000 Template-Plugin-DateTime-0.06002/t/01-sanity.t000644 000765 000024 00000004006 11616374773 021346 0ustar00daisukestaff000000 000000 #!perl use strict; use Test::More (tests => 9); BEGIN { use_ok("Template::Plugin::DateTime"); } use Template; my $dt; my $output; my $tt = Template->new({ POST_CHOMP => 1 }); my $template = < 2000, month => 1, day => 1 ) %] [% date.datetime %] EOM $tt->process(\$template, undef, \$output); $dt = DateTime->new(year => 2000, month => 1, day => 1); is($output, $dt->datetime); $output = ''; $template = <process(\$template, undef, \$output); $dt = DateTime->now(); # time will be different, but that's okay. is($output, $dt->datetime); $output = ''; $template = <process(\$template, undef, \$output); $dt = DateTime->today(); is($output, $dt->datetime); $output = ''; $template = <process(\$template, undef, \$output); $dt = DateTime->last_day_of_month(year => 2004, month => 2); is($output, $dt->datetime); $output = ''; $template = <process(\$template, undef, \$output); like($output, qr(^ok$)); $output = ''; $template = <process(\$template, undef, \$output); like($output, qr(^ok$)); $output = ''; $template = < 2005, month => 7, day => 13, time_zone => 'Asia/Tokyo') %] [% date.datetime %] EOM $tt->process(\$template, undef, \$output); is($output, "2005-07-13T00:00:00"); $output = ''; $template = < '2008-05-30 10:00:00', pattern => '%Y-%m-%d %H:%M:%S') %] [% date.datetime %] EOM $tt->process(\$template, undef, \$output); is($output, "2008-05-30T10:00:00"); Template-Plugin-DateTime-0.06002/t/99_pod-coverage.t000644 000765 000024 00000000527 11616374773 022521 0ustar00daisukestaff000000 000000 use strict; use Test::More; BEGIN { if (! $ENV{TEST_POD}) { plan skip_all => "Enable TEST_POD environment variable to test POD"; } else { eval "use Test::Pod::Coverage"; plan skip_all => "Test::Pod::Coverage required for testing pod coverage" if $@; Test::Pod::Coverage::all_pod_coverage_ok(); } } Template-Plugin-DateTime-0.06002/t/99_pod.t000644 000765 000024 00000000420 11616374773 020720 0ustar00daisukestaff000000 000000 use Test::More; use strict; if (! $ENV{TEST_POD}) { plan skip_all => "Enable TEST_POD environment variable to test POD"; } else { eval "use Test::Pod 1.00"; plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; Test::Pod::all_pod_files_ok(); } Template-Plugin-DateTime-0.06002/lib/Template/000755 000765 000024 00000000000 11616375652 021507 5ustar00daisukestaff000000 000000 Template-Plugin-DateTime-0.06002/lib/Template/Plugin/000755 000765 000024 00000000000 11616375652 022745 5ustar00daisukestaff000000 000000 Template-Plugin-DateTime-0.06002/lib/Template/Plugin/DateTime.pm000644 000765 000024 00000010101 11616375564 024772 0ustar00daisukestaff000000 000000 package Template::Plugin::DateTime; use strict; use warnings; use DateTime; use DateTime::Format::Strptime; use Template::Plugin; use vars qw($AUTHORITY $VERSION @ISA); BEGIN { $VERSION = '0.06002'; $AUTHORITY = 'cpan:DMAKI'; @ISA = (qw(Template::Plugin)); } sub new { my $class = shift; my $context = shift; my %args = ref($_[0]) eq 'HASH' ? %{$_[0]} : (); # boolean args: now, today, last_day_of_month foreach my $arg (qw(now today last_day_of_month)){ if (delete $args{$arg}) { return DateTime->$arg(%args); } } # args that require to proxy the parameter: from_epoch, from_object if (my $epoch = delete $args{from_epoch}) { return DateTime->from_epoch(epoch => $epoch, %args); } elsif (my $object = delete $args{from_object}) { return DateTime->from_object(object => $object, %args); } elsif (my $timestr = delete $args{from_string}) { my $pattern = delete $args{pattern} || '%Y-%m-%d %H:%M:%S'; my $parser = DateTime::Format::Strptime->new( pattern => $pattern, %args); my $dt = $parser->parse_datetime($timestr); return $dt; } # none of the above, use regular call to new. return DateTime->new(%args); } 1; __END__ =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: USE date = DateTime(year = 2004, month = 4, day = 1); -OR- by passing a pattern to parse a date by string using DateTime::Format::Strptime USE date = DateTime(from_string => '2008-05-30 00:00:00', pattern => '%Y-%m-%d %H:%M:%S', time_zone => 'America/New_York'); =head1 METHODS =head2 new This is used internally. You won't be using it from your templates. =head1 CONSTRUCTOR The constructor is exactly the same as that of Datetime.pm, except you can pass optional parameters to it to toggle between different underlying 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 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 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 parameter is a boolean value, and C and C parameters must be specified. [% USE date = DateTime(last_day_of_month = 1, year = 2004, month = 4 ) %] =item from_string Creates a DateTime object by calling DateTime::Format::Strptime The value for the c parameter is a string value, and C parameters is optional and defaults to '%Y-%m-%d %H:%M:%S'. See L for other optional parameters. [% USE date = DateTime(from_string => '2008-05-30 10:00:00', pattern => '%Y-%m-%d %H:%M:%S') %] =back =head1 SEE ALSO L L L