]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Cache the DateTimeZon objects
authorMike Cochrane <mikec@mikenz.geek.nz>
Thu, 24 Jul 2008 23:46:19 +0000 (19:46 -0400)
committerMike Cochrane <mikec@mikenz.geek.nz>
Thu, 24 Jul 2008 23:46:19 +0000 (19:46 -0400)
darcs-hash:20080724234619-533db-015a2751ade3b5b8befb8a735fe89acd4742c4b9.gz

lib/util.php

index 9e3bc3d4972bbba0244b21837fd0613f5f88c18d..4702bdb63f90680ecbcb0114fcdc24a0031b72a4 100644 (file)
@@ -941,9 +941,17 @@ function common_date_string($dt) {
 }
 
 function common_exact_date($dt) {
+    static $_utc;
+    static $_siteTz;
+
+    if (!$_utc) {
+        $_utc = new DateTimeZone('UTC');
+        $_siteTz = new DateTimeZone(common_timezone());
+    }
+
        $dateStr = date('d F Y H:i:s', strtotime($dt));
-       $d = new DateTime($dateStr, new DateTimeZone('UTC'));
-       $d->setTimezone(new DateTimeZone(common_timezone()));
+       $d = new DateTime($dateStr, $_utc);
+       $d->setTimezone($_siteTz);
        return $d->format(DATE_RFC850);
 }