NAME
Mojolicious::Plugin::Human - Helpers to print values as human readable form.
SYNOPSIS
$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'
DESCRIPTION
You can use this module in Mojo template engine to make you users happy.
CONFIGURATION
- money_format
-
Set printf like money format. Default %.2f
- money_delim
-
Set format for human readable delimiter of money. Default: .
- money_digit
-
Set format for human readable digits of money. Default: ,
- datefull
-
Set full format for human readable date and time. Default: %F %T
- datetime
-
Set format for human readable date and time. Default: %F %H:%M
- time
-
Set format for human readable time. Default: %H:%M:%S
- date
-
Set format for human readable date. Default: %F
- tz
-
Set default time zone for DateTime. Default: local
- tz_force
-
Force use time zone
-
Set default cookie name for extract time zone from client. Default: tz
- interval_format
-
Set default time format for intervals. Default : %0.2d:%0.2d:%0.2d
- phone_country
-
Set country code for phones functions. Default: 7
- suffix_one
-
Set default suffix for 1 value. DEPRICATED!
- suffix_two
-
Set default suffix for value between 2 and 5. DEPRICATED!
- suffix_many
-
Set default suffix for other values. DEPRICATED!
- cut_length
-
Set default max length for human_cut. Default: 8
DATE AND TIME HELPERS
str2datetime $str, $tz
Get string or number, return DateTime object. Optional get $tz timezone.
str2time $str, $tz
Get string, return timestamp. Optional get $tz timezone.
strftime $str, $tz
Get string, return formatted string. Optional get $tz timezone.
human_datetime $str, $tz
Get string, return date and time string in human readable form. Optional get $tz timezone.
human_time $str, $tz
Get string, return time string in human readable form. Optional get $tz timezone.
human_date $str, $tz
Get $str string, return date string in human readable form. Optional get $tz timezone.
human_interval $sec
Get count of seconds and return interval human readable form.
MONEY HELPERS
human_money $str
human_money $format, $str
Get number, return money string in human readable form with levels.
human_money_short $str
human_money_short $format, $str
Like human_money but discard zeros.
PHONE HELPERS
flat_phone $str, $country
Get srtring, return flat phone string.
human_phone $str, $country, $add
Get srtring, return phone string in human readable form.
human_phones $str, $country, $add
Get srtring, return phones (if many) string in human readable form.
TEXT HELPERS
human_suffix $str, $count, $one, $two, $many
Get word base form and add some of suffix ($one, $two, $many) depends of $count DEPRICATED!
human_suffix_ru $count, $one, $two, $many
Get word form for ($one, $two, $many) depends of $count
human_cut $str, $length
Return string cut off $length and ellipsis in the end.
DISTANCE HELPERS
human_distance $dist
Return distance, without fractional part if possible.
AUTHORS
Dmitry E. Oboukhov <unera@debian.org>, Roman V. Nikolaev <rshadow@rambler.ru>
COPYRIGHT
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.