diff options
Diffstat (limited to 'extensions/BugModal/Extension.pm')
-rw-r--r-- | extensions/BugModal/Extension.pm | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/extensions/BugModal/Extension.pm b/extensions/BugModal/Extension.pm index 04d7cb567..0bc96e730 100644 --- a/extensions/BugModal/Extension.pm +++ b/extensions/BugModal/Extension.pm @@ -14,12 +14,13 @@ use base qw(Bugzilla::Extension); use Bugzilla::Extension::BugModal::ActivityStream; use Bugzilla::Extension::BugModal::MonkeyPatches; +use Bugzilla::Extension::BugModal::Util qw(date_str_to_time); use Bugzilla::Constants; use Bugzilla::User::Setting; use Bugzilla::Util qw(trick_taint datetime_from html_quote); use List::MoreUtils qw(any); use Template::Stash; -use Time::Duration; +use Time::Duration qw(ago); our $VERSION = '1'; @@ -62,7 +63,7 @@ sub template_after_create { my ($timestamp) = @_; my $datetime = datetime_from($timestamp) // return $timestamp; - return ago(time() - $datetime->epoch); + return ago(abs(time() - $datetime->epoch)); }; }, 1 ); @@ -85,6 +86,17 @@ sub template_after_create { }, 1 ); + # parse date string and output epoch + $context->define_filter( + epoch => sub { + my ($context) = @_; + return sub { + my ($date_str) = @_; + return date_str_to_time($date_str); + }; + }, 1 + ); + # flatten a list of hashrefs to a list of values # eg. logins = users.pluck("login") $context->define_vmethod( |