NAME

Template::Plugin::DtFormatter - Easily create formatted string from DateTime objects

SYNOPSIS

[% USE DtFormatter %]
[% DtFromatter.format(mydt, 'human') %]

15/February/2007, 11:55

[% DtFromatter.format(mydt, 'hm') %]

11:55

DESCRIPTION

This modules provides a simple mean of formatting DateTime object in TT templates. It provides some predefined formatter formatters, and you can extend it by providing your own or overriding existing ones.

The advantage of dtformatter is that, basically, it provides human-readable shortcuts for format strings, which allow you to just modify the formatter in the module configuration to affect all the dates displayed using it.

Use this way:

[% USE DtFormatter %]
[% DtFormatter.format(DateTime_object, formatter_name) %]

PREDEFINED FORMATTERS

These are the predefined formatters. They all use DateTime::Format::Strptime, so that is the only dependency of this module.

sql         => DateTime::Format::Strptime->new(pattern => '%Y-%m-%d %H:%M:%S'),
sql_date    => DateTime::Format::Strptime->new(pattern => '%Y-%m-%d'),
human       => DateTime::Format::Strptime->new(pattern => '%d/%m/%Y, %H:%M'),
human_date  => DateTime::Format::Strptime->new(pattern => '%d/%m/%Y'),
hm          => DateTime::Format::Strptime->new(pattern => '%H:%M'),
hms         => DateTime::Format::Strptime->new(pattern => '%H:%M:%S'),

SEE ALSO

Template, DateTime.

AUTHOR

Michele Beltrame, mb@italpro.net.

LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.