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 !
* Timezone refactoring/fixes.
  * Added set_timezone() and get_timezone().
  * timezones() now undoes the current timezone, instead of the config setting.
  * Set the timezone to an offset of 0 in install.php so it ignores the server's 
  settings.
* Fixed TESTER constant in installer.php
vito (author)
Wed Sep 03 18:12:10 -0700 2008
commit  3adf78dfab6e39235682694388d7913361a3a7a4
tree    bfd1cdee5fc70bf78a955d792390826afa2c9686
parent  c71daaba73c6538dc94d64108eadc3f47c6f7b5f
...
98
99
100
101
102
103
104
 
105
106
107
...
98
99
100
 
 
 
 
101
102
103
104
0
@@ -98,10 +98,7 @@
0
   require_once INCLUDES_DIR."/lib/gettext/gettext.php";
0
   require_once INCLUDES_DIR."/lib/gettext/streams.php";
0
 
0
-  if (function_exists("date_default_timezone_set"))
0
-    date_default_timezone_set($config->timezone);
0
-  else
0
-    ini_set("date.timezone", $config->timezone);
0
+  set_timezone($config->timezone);
0
 
0
   header("X-Pingback: ".$config->chyrp_url."/includes/xmlrpc.php");
0
 
...
1696
1697
1698
1699
 
1700
1701
1702
...
1696
1697
1698
 
1699
1700
1701
1702
0
@@ -1696,7 +1696,7 @@
0
         closedir($open);
0
       }
0
 
0
-      $this->context["timezones"] = timezones(true);
0
+      $this->context["timezones"] = timezones();
0
 
0
       if (empty($_POST))
0
         return;
...
1049
1050
1051
1052
 
1053
1054
1055
1056
1057
 
1058
1059
1060
...
1067
1068
1069
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1070
1071
1072
...
1049
1050
1051
 
1052
1053
1054
1055
1056
 
1057
1058
1059
1060
...
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
0
@@ -1049,12 +1049,12 @@
0
 
0
     $zones = array();
0
     $offsets = array();
0
-    $reverse = (isset(Config::current()->timezone)) ? $timezones[Config::current()->timezone] : 0 ;
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() - $reverse + $offset);
0
+                         "now" => time() - $undo + $offset);
0
     }
0
 
0
     function by_time($a, $b) {
0
@@ -1067,6 +1067,31 @@
0
   }
0
 
0
   /**
0
+   * Function: set_timezone
0
+   * Sets the timezone.
0
+   *
0
+   * Parameters:
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
+  }
0
+
0
+  /**
0
+   * Function: get_timezone()
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
+  }
0
+
0
+  /**
0
    * Function: error_panicker
0
    * Exits and states where the error occurred.
0
    */
...
10
11
12
13
 
 
14
15
16
...
23
24
25
 
 
 
 
26
27
28
...
10
11
12
 
13
14
15
16
17
...
24
25
26
27
28
29
30
31
32
33
0
@@ -10,7 +10,8 @@
0
   define('XML_RPC', false);
0
   define('UPGRADING', false);
0
   define('INSTALLING', true);
0
-  define('TESTER', true);
0
+
0
+  define('TESTER', isset($_SERVER['HTTP_USER_AGENT']) and $_SERVER['HTTP_USER_AGENT'] == "tester.rb");
0
 
0
   ini_set('error_reporting', E_ALL);
0
   ini_set('display_errors', true);
0
@@ -23,6 +24,10 @@
0
   # Helpers
0
   require INCLUDES_DIR."/helpers.php";
0
 
0
+  # Atlantic/Reykjavik is 0 offset. Set it so the timezones() function is
0
+  # always accurate, even if the server has its own timezone settings.
0
+  set_timezone("Atlantic/Reykjavik");
0
+
0
   require_once INCLUDES_DIR."/class/Query.php";
0
   require_once INCLUDES_DIR."/class/QueryBuilder.php";
0
   require_once INCLUDES_DIR."/lib/YAML.php";

Comments