diff options
author | Dave Lawrence <dlawrence@mozilla.com> | 2013-03-22 22:24:09 +0100 |
---|---|---|
committer | Dave Lawrence <dlawrence@mozilla.com> | 2013-03-22 22:24:09 +0100 |
commit | ddf489ad8abf9e0afa3d4545e784eab7c854bcbe (patch) | |
tree | 649afd9c344e95168653179b66432ec35af96a2a /extensions | |
parent | 2b88ae92c4970f0ff5cccb5b607902f8752590c2 (diff) | |
download | bugzilla-ddf489ad8abf9e0afa3d4545e784eab7c854bcbe.tar.gz bugzilla-ddf489ad8abf9e0afa3d4545e784eab7c854bcbe.tar.xz |
Bug 853913 - Some MyDashboard "updated" friendly dates are inappropriate and/or broken w.r.t. timezones
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/MyDashboard/lib/Queries.pm | 9 | ||||
-rw-r--r-- | extensions/MyDashboard/lib/TimeAgo.pm | 6 |
2 files changed, 7 insertions, 8 deletions
diff --git a/extensions/MyDashboard/lib/Queries.pm b/extensions/MyDashboard/lib/Queries.pm index 5a3bf0cc6..7703a29c2 100644 --- a/extensions/MyDashboard/lib/Queries.pm +++ b/extensions/MyDashboard/lib/Queries.pm @@ -131,7 +131,8 @@ sub QUERY_DEFS { sub query_bugs { my $qdef = shift; my $dbh = Bugzilla->dbh; - my $date_now = DateTime->now; + my $user = Bugzilla->user; + my $date_now = DateTime->now(time_zone => $user->timezone); ## HACK to remove POST delete $ENV{REQUEST_METHOD}; @@ -149,7 +150,7 @@ sub query_bugs { foreach my $column (SELECT_COLUMNS) { $bug->{$column} = shift @$row; if ($column eq 'changeddate') { - $bug->{$column} = format_time($bug->{$column}, '%Y-%m-%d %H:%M'); + $bug->{$column} = format_time($bug->{$column}); my $date_then = datetime_from($bug->{$column}); $bug->{'changeddate_fancy'} = time_ago($date_then, $date_now); } @@ -164,7 +165,7 @@ sub query_flags { my ($type, $include_resolved) = @_; my $user = Bugzilla->user; my $dbh = Bugzilla->dbh; - my $date_now = DateTime->now; + my $date_now = DateTime->now(time_zone => $user->timezone); ($type ne 'requestee' || $type ne 'requester') || ThrowCodeError('param_required', { param => 'type' }); @@ -244,7 +245,7 @@ sub query_flags { # Format the updated date specific to the user's timezone and add the fancy version foreach my $flag (@$flags) { - $flag->{'updated'} = format_time($flag->{'updated'}, '%Y-%m-%d %H:%M'); + $flag->{'updated'} = format_time($flag->{'updated'}); my $date_then = datetime_from($flag->{'updated'}); $flag->{'updated_fancy'} = time_ago($date_then, $date_now); } diff --git a/extensions/MyDashboard/lib/TimeAgo.pm b/extensions/MyDashboard/lib/TimeAgo.pm index b870a292e..78badf5fa 100644 --- a/extensions/MyDashboard/lib/TimeAgo.pm +++ b/extensions/MyDashboard/lib/TimeAgo.pm @@ -84,14 +84,12 @@ sub time_ago { croak('Invalid second parameter provided to DateTime::Duration::Fuzzy::time_ago; it must be a DateTime object if provided') } - my $now_clone = $now->clone->set_time_zone(Bugzilla->user->timezone); - my $time_clone = $time->clone->set_time_zone(Bugzilla->user->timezone); - my $dur = $now_clone->subtract_datetime_absolute( $time_clone )->in_units('seconds'); + my $dur = $now->subtract_datetime_absolute($time)->in_units('seconds'); foreach my $range ( @ranges ) { if ( $dur <= $range->[0] ) { if ( $range->[2] ) { - return $range->[2]->( $time_clone, $now_clone ) + return $range->[2]->($time, $now) } return $range->[1] } |