in reply to smart human readable time epoch

DateTime::Format::Human::Duration

Replies are listed 'Best First'.
Re^2: smart human readable time epoch
by ikegami (Patriarch) on Jun 15, 2011 at 09:48 UTC
    Usage:
    use DateTime::Format::Human::Duration qw( ); my $formatter = DateTime::Format::Human::Duration->new(); sub format_duration { my ($dur) = @_; return $formatter->format_duration($dur, past => '%s ago', future => 'in %s', no_time=> 'now', ); }

    Creating the argument is done using the same code as Re: smart human readable time epoch.

    I'm still getting bad results, though. I think the module has a few bugs.

Re^2: smart human readable time epoch
by rakzer (Novice) on Jun 15, 2011 at 09:37 UTC
    I tried that one but i get:
    perl -e 'use DateTime; use DateTime::Format::Human::Duration; my $span + = DateTime::Format::Human::Duration->new(); print $span->format_dura +tion(234234234);' Can't call method "in_units" without a package or object reference at +/usr/local/lib/perl5/site_perl/5.12.3/DateTime/Format/Human/Duration. +pm line 27.
    Not sure if it's cruft or missing something. That's with perl v5.12.3.
      What you're missing is the proper usage of the function. It is documented to take a DateTime::Duration object.