I have the pleasure to announce the release of the new Perl module
DateTime::Format::RelativeTime
<https://metacpan.org/pod/DateTime::Format::RelativeTime>, which is
designed to mirror its equivalent Web API Intl.RelativeTimeFormat
<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat>
It requires only Perl v5.10.1 to run, and uses an exception class to
return error or to die (if the option fatal is provided and set to a
true value).
You can use it the same way as the Web API:
use DateTime::Format::RelativeTime; my $fmt =
DateTime::Format::RelativeTime->new( # You can use en-GB (Unicode /
web-style) or en_GB (system-style), it does not matter. 'en_GB', {
localeMatcher => 'best fit', # see
getNumberingSystems() in Locale::Intl for the supported number systems
numberingSystem => 'latn', # Possible values are: long,
short or narrow style => 'short', # Possible values are:
always or auto numeric => 'always', }, ) || die(
DateTime::Format::RelativeTime->error ); # Format relative time using
negative value (-1). $fmt->format( -1, 'day' ); # "1 day ago" # Format
relative time using positive value (1). $fmt->format( 1, 'day' ); # "in
1 day"
You can read more about it on Perl.com here:
https://www.perl.com/article/release-of-new-module-datetime-format-relativetime/#author-bio-jacques-deguest
Regards,
Jacques Deguest