Albert Cornelissen

NAME

Template::Plugin::FriendlyDelta - A Template Toolkit plugin filter to show a human friendly time delta between a supplied date and now

SYNOPSIS

  In your template:
  [% USE FriendlyDelta %]
  
  [%  '2014-09-09T12:23:07' | friendlydelta %]
    
    or 
    
  [%  '2014-09-09T12:23:07' | friendlydelta($custom_format_hash) %]
 
 

DESCRIPTION

See above for use in your templates. You can also pass two arguments: a hash to change the display, and a modifier for when you want to use custom plurals.

Structure of the format / display hash: my $format_hash = { month => { 1 => 'January', 2 => 'February', 3 => 'March', 4 => 'April', 5 => 'May', 6 => 'June', 7 => 'July', 8 => 'August', 9 => 'September', 10 => 'October', 11 => 'November', 12 => 'December' }, unit => { m => 'minute', h => 'hour', d => 'day', }, return_format => '$quantity $duration ago' }

If you do your own string replacement for plurals in $format_hash->{'return_format'}, pass 1 after: [% '2014-09-09T12:23:07' | friendlydelta($format_hash, 1) %]

AUTHOR

Albert Cornelissen, <acorn@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2014 by Albert Cornelissen

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available.