Skip to content

Commit e2f48e6

Browse files
committed
fixed #95
1 parent beff2bc commit e2f48e6

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

lib/OpenCloud/Globals.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,6 @@
126126
*/
127127
//define('RAXSDK_CACERTPEM', __DIR__ . DIRECTORY_SEPARATOR . 'cacert.pem');
128128

129-
// set the default timezone
130-
date_default_timezone_set(RAXSDK_TIMEZONE);
131-
132129
/* these should not be overridden */
133130
define('RAXSDK_VERSION', '1.5.4');
134131
define('RAXSDK_USER_AGENT', 'php-opencloud/'.RAXSDK_VERSION.' (Rackspace)');
@@ -172,6 +169,21 @@
172169
*/
173170
define('RAX_PRIVATE','11111111-1111-1111-1111-111111111111');
174171

172+
/********** TIMEZONE MAGIC **********/
173+
174+
/**
175+
* This is called if there is an error getting the default timezone;
176+
* that means that the default timezone isn't set.
177+
*/
178+
function __raxsdk_timezone_set($errno, $errstr) {
179+
if ($errno==2)
180+
date_default_timezone_set(RAXSDK_TIMEZONE);
181+
else
182+
die(sprintf("Unknown error %d: %s\n", $errno, $errstr));
183+
}
184+
set_error_handler('\OpenCloud\__raxsdk_timezone_set');
185+
@date_default_timezone_get();
186+
restore_error_handler();
175187

176188
/********** SOME GLOBAL FUNCTIONS **********/
177189

0 commit comments

Comments
 (0)