NAME
DateTime::TimeAgo -- express dates as fuzzy human-friendly strings
SYNOPSIS
use DateTime::TimeAgo qw(time_ago);
use DateTime;
my $now = DateTime->new(
year => 2010, month => 12, day => 12,
hour => 19, minute => 59,
);
my $then = DateTime->new(
year => 2010, month => 12, day => 12
hour => 15,
);
print time_ago($then, $now);
# outputs 'several hours ago'
print time_ago($then);
# $now taken from C<time> function
my $DateTime_object = DateTime::TimeAgo::get_datetime_from_timestamp(time);
DESCRIPTION
DateTime::TimeAgo is inspired from the timeAgo jQuery module http://timeago.yarp.com/.
It takes two DateTime objects -- first one representing a moment in the past and second optional one representine the present, and returns a human-friendly fuzzy expression of the time gone.
functions
- time_ago($then, $now)
-
The only exportable function.
First obligatory parameter is a DateTime object.
Second optional parameter is also a DateTime object. If it's not provided, then now as the
time
function returns is substituted.Returns a string expression of the interval between the two DateTime objects, like
several hours ago
,yesterday
or <last century>. - get_datetime_from_timestamp($unix_timestamp);
-
Not exportable.
Returns a DateTime object based on the provided timestamp, as returned by the
time
function.
AUTHOR
Jan Oldrich Kruza, <sixtase at cpan.org>
LICENSE AND COPYRIGHT
Copyright 2010 Jan Oldrich Kruza.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.