The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

DateTime::Duration::Fuzzy -- express dates as fuzzy human-friendly strings

SYNOPSIS

 use DateTime::Duration::Fuzzy 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

DESCRIPTION

DateTime::Duration::Fuzzy 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>.

performance

On 64bit machines, it is asvisable to 'use integer', which makes the calculations faster. You can turn this on by setting the ARCH_64BIT environmental variable to a true value.

If you do this on a 32bit machine, you will get wrong results for intervals starting with "several decades ago".

AUTHOR

Jan Oldrich Kruza, <sixtease 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.