madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r20224: LJSUP-9905: Entry time convert to user's...

Committer: sbelyaev
LJSUP-9905: Entry time convert to user's time zone.
U   trunk/cgi-bin/LJ/DelayedEntry.pm
Modified: trunk/cgi-bin/LJ/DelayedEntry.pm
===================================================================
--- trunk/cgi-bin/LJ/DelayedEntry.pm	2011-10-05 03:14:44 UTC (rev 20223)
+++ trunk/cgi-bin/LJ/DelayedEntry.pm	2011-10-05 03:55:14 UTC (rev 20224)
@@ -668,10 +668,24 @@
     #                                         $journal->userid,
     #                                         $userid );
 
+    my $tz = $user->prop("timezone");
+    my $timezones = DateTime::TimeZone->new( name => $tz );
+
+    my $dt = DateTime->now( 'time_zone' => 'UTC');
+    my $offset = $timezones->offset_for_datetime($dt); 
+
+    my $daterequest;
+    if ($tz) {
+        $daterequest = "DATE_FORMAT(ADDDATE(posttime, INTERVAL $offset SECOND), \"$dateformat\") AS 'alldatepart', " .
+                       "DATE_FORMAT(ADDDATE(logtime,  INTERVAL $offset SECOND), \"$dateformat\") AS 'system_alldatepart' ";
+    } else {
+        $daterequest = "DATE_FORMAT(posttime, \"$dateformat\") AS 'alldatepart', " .
+                       "DATE_FORMAT(logtime, \"$dateformat\") AS 'system_alldatepart' ";
+
+    }
+
     my $opts = $dbcr->selectrow_arrayref("SELECT journalid, delayedid, posterid, " .
-                                         "DATE_FORMAT(posttime, \"$dateformat\") AS 'alldatepart', " .
-                                         "DATE_FORMAT(logtime, \"$dateformat\") AS 'system_alldatepart', " . 
-                                         "logtime " .
+                                         "$daterequest, logtime " .
                                          "FROM delayedlog2 ".
                                          "WHERE journalid=$journalid AND ".
                                          "delayedid = $delayedid");

Tags: livejournal, madeon, pm
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments