NAME

Dancer::Plugin::Formatter - Data formatter for Dancer

VERSION

version 0.05

DESCRIPTION

Provides an easy way to reformat time/date and other data in templates.

CONFIGURATION

In your configuration file, make sure you have enable this plugin. You can list options right here:

plugins:
  Formatter:
    default_time_format: "%a, %x - %X"

or default format can be changed later:

# in code
$Dancer::Plugin::Formatter::default_time_format = '%Y%m%d';

# in template
: set_default_date_format('%Y%m%d');

USAGE

# in template
<: $today | format_date()  :><!-- use default date/time format -->
<: $e     | format('%.7f') :><!-- sprintf's format rules -->

METHODS

format

Format string or number by the usual "printf" conventions of the C library function "sprintf". See sprintf, sprintf(3) or printf(3) on your system for an explanation of the general principles.

Example:

<: $pi | format('%.4f') :>

will may return 3.1416.

format_time

Parse provided date/time via Date::Parse::strptime and print it as arbitrary string. See strftime(3) for format explanation.

format_time('21/dec/42 17:05', '%Y, %e %B, %A');

or

<% date('2015-01-25') %>
<% $date_variable | date %>

Input can have any format which recognized by Date::Parse:

1995:01:24T09:08:17.1823213           ISO-8601
1995-01-24T09:08:17.1823213
Wed, 16 Jun 94 07:29:35 CST           Comma and day name are optional
Thu, 13 Oct 94 10:13:13 -0700
Wed, 9 Nov 1994 09:50:32 -0500 (EST)  Text in ()'s will be ignored.
21 dec 17:05                          Will be parsed in the current time zone
21-dec 17:05
21/dec 17:05
21/dec/93 17:05
1999 10:02:18 "GMT"
16 Nov 94 22:28:20 PST

format_date

Same as above but default date/time format stored in $Dancer::Plugin::Formatter::default_time_format and can be changed via set_default_date_format.

set_default_time_format

Sets default format for time output.

set_default_time_format('%m/%d/%y')

See strftime(3) for format explanation.

set_default_date_format

Same as above, for $Dancer::Plugin::Formatter::default_time_format.

CONTRIBUTING

This module is developed on Github at:

http://github.com/shoorick/dancer-plugin-formatter

BUGS

Please report any bugs or feature requests to bug-dancer-plugin-formatter at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Dancer-Plugin-Formatter or to Github at https://github.com/shoorick/dancer-plugin-formatter/issues

I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Dancer::Plugin::Formatter

You can also look for information at:

SEE ALSO

Dancer, POSIX, strftime(3), sprintf, sprintf(3) or printf(3)

COPYRIGHT AND LICENSE

Copyright 2015 Alexander Sapozhnikov <shoorick@cpan.org> http://shoorick.ru

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

See http://dev.perl.org/licenses/ for more information.