summaryrefslogtreecommitdiffstats
path: root/extensions/BugModal/Extension.pm
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2015-04-14 07:20:00 +0200
committerByron Jones <glob@mozilla.com>2015-04-14 07:20:00 +0200
commite5131c86c22c5577c0e27db04481084caf635dc5 (patch)
tree897a6ef2d1314a1c442e9e8b8ff14a4dd2cf3eb2 /extensions/BugModal/Extension.pm
parent6116f2f7cf32f40c1f943cef3f523ed5955f968d (diff)
downloadbugzilla-e5131c86c22c5577c0e27db04481084caf635dc5.tar.gz
bugzilla-e5131c86c22c5577c0e27db04481084caf635dc5.tar.xz
Bug 1146767: update relative dates without refreshing the page
Diffstat (limited to 'extensions/BugModal/Extension.pm')
-rw-r--r--extensions/BugModal/Extension.pm16
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(