public
Description: The ultra-lightweight ultra-flexible blogging engine with a fetish for birds and misspellings.
Homepage: http://chyrp.net/
Clone URL: git://github.com/vito/chyrp.git
Click here to lend your support to: chyrp and make a donation at www.pledgie.com !
Updated the timezone listing to be more precise.
vito (author)
Sat Nov 01 11:56:54 -0700 2008
commit  840e868b6db018f7439edfb7343a81fcdea6d324
tree    de0aff6cff2c11ebeae32fbca282723c8ae5bcab
parent  2205f5ceac450786017b4a0551f9ea7647e18c30
...
37
38
39
40
 
41
42
43
...
37
38
39
 
40
41
42
43
0
@@ -37,7 +37,7 @@
0
                         <label for="timezone">${ "What time is it?" | translate }</label>
0
                         <select name="timezone" id="timezone">
0
                         {% for zone in timezones %}
0
-                            <option value="$zone.name"${ zone.name | option_selected(site.timezone) }>${ zone.now | strftime("%I:%M %p on %B %e, %Y" | translate) } (GMT{% if zone.offset >= 0 %}+{% endif %}$zone.offset)</option>
0
+                            <option value="$zone.name"${ zone.name | option_selected(site.timezone) }>${ zone.now | strftime("%I:%M %p on %B %e, %Y" | translate) } &mdash; $zone.name</option>
0
                         {% endfor %}
0
                         </select>
0
                     </p>
...
1226
1227
1228
 
 
 
 
 
 
 
 
 
 
 
 
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
 
 
 
 
 
1244
1245
1246
 
1247
1248
1249
...
1259
1260
1261
1262
1263
1264
1265
 
1266
1267
1268
...
1270
1271
1272
1273
1274
1275
1276
 
1277
1278
1279
...
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
 
 
1245
 
 
 
 
 
 
 
 
1246
1247
1248
1249
1250
1251
1252
 
1253
1254
1255
1256
...
1266
1267
1268
 
 
 
 
1269
1270
1271
1272
...
1274
1275
1276
 
 
 
 
1277
1278
1279
1280
0
@@ -1226,24 +1226,31 @@
0
     }
0
 
0
     /**
0
+     * Function: datetimetotime
0
+     * Converts a DateTime to an integer time.
0
+     */
0
+    function datetimetotime($datetime) {
0
+        #$old = get_timezone();
0
+        #set_timezone($datetime->getTimezone()->getName());
0
+        $time = strtotime(strftime($datetime->format("F jS, Y, g:i A")));
0
+        #set_timezone($old);
0
+        return $time;
0
+    }
0
+
0
+    /**
0
      * Function: timezones
0
      * Returns an array of timezones that have unique offsets. Doesn't count deprecated timezones.
0
      */
0
     function timezones() {
0
-        require INCLUDES_DIR."/lib/timezones.php"; # $timezones
0
-
0
         $zones = array();
0
-        $offsets = array();
0
-        $undo = $timezones[get_timezone()];
0
-        foreach ($timezones as $timezone => $offset) {
0
-            if (!in_array($offset, $offsets))
0
-                $zones[] = array("offset" => ($offsets[] = $offset) / 3600,
0
-                                 "name" => $timezone,
0
-                                 "now" => time() - $undo + $offset);
0
-        }
0
+
0
+        foreach (DateTimeZone::listIdentifiers() as $zone)
0
+            if (substr($zone, 0, 4) != "Etc/" and !in_array($zone, array("GMT+0", "GMT-0", "Greenwich", "GMT0")))
0
+                $zones[] = array("name" => $zone,
0
+                                 "now" => datetimetotime(new DateTime("now", new DateTimeZone($zone))));
0
 
0
         function by_time($a, $b) {
0
-            return ($a["now"] < $b["now"]) ? -1 : 1;
0
+            return (int) ($a["now"] > $b["now"]);
0
         }
0
 
0
         usort($zones, "by_time");
0
@@ -1259,10 +1266,7 @@
0
      *     $timezone - The timezone to set.
0
      */
0
     function set_timezone($timezone) {
0
-        if (function_exists("date_default_timezone_set"))
0
-            date_default_timezone_set($timezone);
0
-        else
0
-            ini_set("date.timezone", $timezone);
0
+        date_default_timezone_set($timezone);
0
     }
0
 
0
     /**
0
@@ -1270,10 +1274,7 @@
0
      * Returns the current timezone.
0
      */
0
     function get_timezone() {
0
-        if (function_exists("date_default_timezone_set"))
0
-            return date_default_timezone_get();
0
-        else
0
-            return ini_get("date.timezone");
0
+        return date_default_timezone_get();
0
     }
0
 
0
     /**

Comments