Open GoogleCodeExporter opened 9 years ago
Hmm. Perhaps work arounds from the authors are not speedy.
I am in the UK and adding:
date_default_timezone_set('UTC');
after the ); which terminates the constants array in
..home/Library/Widgets/PHPfr.wdgt/Assets/php/date.php
works for me. If you are in another timezone, then you can do this by hand. See
below for context.
I had sort of expected that
date_default_timezone_set(date_default_timezone_get());
would work - but it didn't. The code needs to look at the system to get the
timezone, if Apple isn't prepared to get php configured 'properly', it
probably needs to use some posix type lookups to get the system time and set
the timezone correctly. However, I suggest that you use the widget
and lookup
date_default_timezone_set
to find the timezone for you - then the quick and dirty hack will also work.
Here's the context for the code change - replace UTC by your timezone.
Old code:
'DATE_W3C' => DATE_W3C
);
if (!isset($argv[1]) || '' == $argv[1]) {
$return = ' ';
New code:
'DATE_W3C' => DATE_W3C
);
date_default_timezone_set('UTC');
if (!isset($argv[1]) || '' == $argv[1]) {
$return = ' ';
Original comment by p...@hillside.co.uk
on 10 Nov 2009 at 6:47
Thanks for alerting me to this. I expect Apple will fix this issue in a future
OS release, but I will add your patch to
the date parsing script in the meantime.
Original comment by segdeha
on 10 Nov 2009 at 7:13
I've been looking to see if there is a way of identifying the timezone from the
system. It seems to be stored in a pllst - so if you
replace the date_default_timezone_set('UTC') by this code, I think it should
generate local times for people.
I've attempted to make this as safe as possible - but it probably should be
tested on several machines to see if works - seems to
work here of course:
// Use the .GlobalPreferences file to obtain the system timezone
// There is probably some official API that allows the read of
// the property list - but it seems just as easy to use the
// standard system command 'defaults'
$defaultTimezone = 'UTC';
$handle = @popen("/usr/bin/defaults read
/Library/Preferences/.GlobalPreferences
com.apple.TimeZonePref.Last_Selected_City",
"r");
if ($handle) {
$buffer = "";
while (!feof($handle)) {
$buffer .= fread($handle, 8192);
}
pclose($handle);
// this ought to be something that looks like
//(
// "51.500000",
// "-0.166656",
// 11,
// "Europe/London",
// GB,
// London,
// England,
// London,
// England
// )
// and we need line 5
//
$parse = explode(",", $buffer);
if (count($parse) > 4) {
$tz = trim($parse[3]);
if (preg_match('/"([^"]*)"/', $tz, $ma)) {
$defaultTimezone = $ma[1];
}
}
}
if (!date_default_timezone_set($defaultTimezone)) {
date_default_timezone_set("UTC");
}
Original comment by p...@hillside.co.uk
on 10 Nov 2009 at 11:57
Here's my current date.php
Original comment by p...@hillside.co.uk
on 10 Nov 2009 at 11:58
Attachments:
Incidentally PHP expects you to set the timezone in php.ini - and so I don't
think that Apple can really do that
and retain world portability.
Original comment by p...@hillside.co.uk
on 11 Nov 2009 at 12:02
Original issue reported on code.google.com by
p...@hillside.co.uk
on 10 Nov 2009 at 4:45