Mojolicious::Plugin::Human - Helpers to print values as human readable form.
$self->plugin('Human', { # Set money parameters if you need money_delim => ",", money_digit => " ", # Local format for date and time strings datetime => '%d.%m.%Y %H:%M', time => '%H:%M:%S', date => '%d.%m.%Y', phone_country => 1, }); # Controllers $self->human_datetime( time ); # Templates # return '2015-05-23 13:63' %= human_datetime '2015-05-23 13:63:67 +0400'
You can use this module in Mojo template engine to make you users happy.
Set printf like money format. Default %.2f
Set format for human readable delimiter of money. Default: .
Set format for human readable digits of money. Default: ,
Set full format for human readable date and time. Default: %F %T
Set format for human readable date and time. Default: %F %H:%M
Set format for human readable time. Default: %H:%M:%S
Set format for human readable date. Default: %F
Set default time zone for DateTime. Default: local
Force use time zone
Set default cookie name for extract time zone from client. Default: tz
Set default time format for intervals. Default : %0.2d:%0.2d:%0.2d
Set country code for phones functions. Default: 7
Set default suffix for 1 value. DEPRICATED!
Set default suffix for value between 2 and 5. DEPRICATED!
Set default suffix for other values. DEPRICATED!
Set default max length for human_cut. Default: 8
Get string or number, return DateTime object. Optional get $tz timezone.
Get string, return timestamp. Optional get $tz timezone.
Get string, return formatted string. Optional get $tz timezone.
Get string, return date and time string in human readable form. Optional get $tz timezone.
Get string, return time string in human readable form. Optional get $tz timezone.
Get $str string, return date string in human readable form. Optional get $tz timezone.
Get count of seconds and return interval human readable form.
Get number, return money string in human readable form with levels.
Like human_money but discard zeros.
Get srtring, return flat phone string.
Get srtring, return phone string in human readable form.
Get srtring, return phones (if many) string in human readable form.
Get word base form and add some of suffix ($one, $two, $many) depends of $count DEPRICATED!
Get word form for ($one, $two, $many) depends of $count
Return string cut off $length and ellipsis in the end.
Return distance, without fractional part if possible.
Dmitry E. Oboukhov <unera@debian.org>, Roman V. Nikolaev <rshadow@rambler.ru>
Copyright (C) 2011 Dmitry E. Oboukhov <unera@debian.org> Copyright (C) 2011 Roman V. Nikolaev <rshadow@rambler.ru>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
To install Mojolicious::Plugin::Human, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious::Plugin::Human
CPAN shell
perl -MCPAN -e shell install Mojolicious::Plugin::Human
For more information on module installation, please visit the detailed CPAN module installation guide.