fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2010-07-07 10:25 am

[dw-free] ?replyto pages don't use local timezone

[commit: http://hg.dwscoalition.org/dw-free/rev/2c176a71404b]

http://bugs.dwscoalition.org/show_bug.cgi?id=2753

Provide the comment time in the timezone of the current user, and the parent
comment poster, to be consistent with the entry page.

Patch by [personal profile] fu.

Files modified:
  • cgi-bin/LJ/S2/ReplyPage.pm
--------------------------------------------------------------------------------
diff -r a47859f5df81 -r 2c176a71404b cgi-bin/LJ/S2/ReplyPage.pm
--- a/cgi-bin/LJ/S2/ReplyPage.pm	Wed Jul 07 17:58:25 2010 +0800
+++ b/cgi-bin/LJ/S2/ReplyPage.pm	Wed Jul 07 18:31:18 2010 +0800
@@ -194,6 +194,18 @@ sub ReplyPage
 
         my $dtalkid = $re_talkid * 256 + $entry->anum;
         my $cmtobj = LJ::Comment->new( $u, dtalkid => $dtalkid );
+
+        my $tz_remote;
+        my $datetime_remote;
+        my $datetime_poster;
+        if ( $remote ) {
+            my $tz = $remote->prop( "timezone" );
+            $tz_remote = $tz ? eval { DateTime::TimeZone->new( name => $tz); } : undef;
+        }
+
+        $datetime_remote = $tz_remote ? DateTime_tz( $cmtobj->unixtime, $tz_remote ) : undef;
+        $datetime_poster = $parentcomment ? DateTime_tz( $cmtobj->unixtime, $parentcomment->poster ) : undef;
+
         my $replyargs = LJ::viewing_style_args( %$get );
         $replyto = {
             '_type' => 'Comment',
@@ -209,6 +221,8 @@ sub ReplyPage
             'threadroot_url' => $cmtobj->threadroot_url( $replyargs ),
             'time' => $datetime,
             'system_time' => $datetime,
+            'time_remote' => $datetime_remote,
+            'time_poster' => $datetime_poster,
             'tags' => [],
             'talkid' => $dtalkid,
             'link_keyseq' => [ 'delete_comment' ],
--------------------------------------------------------------------------------