mirror of
https://github.com/friendica/friendica
synced 2025-04-25 07:10:11 +00:00
Remove most calls to date_default_timezone_* calls
- It was wrongly used to set the node-wide ot user-specific timezone - It is now fully managed from the App object - Add a static variable to DateTimeFormat maintain the convenient local() method
This commit is contained in:
parent
08c24fd4fa
commit
6db211568a
11 changed files with 35 additions and 36 deletions
|
@ -36,6 +36,13 @@ class DateTimeFormat
|
|||
const HTTP = 'D, d M Y H:i:s \G\M\T';
|
||||
const JSON = 'Y-m-d\TH:i:s.v\Z';
|
||||
|
||||
static $localTimezone = 'UTC';
|
||||
|
||||
public static function setLocalTimeZone(string $timezone)
|
||||
{
|
||||
self::$localTimezone = $timezone;
|
||||
}
|
||||
|
||||
/**
|
||||
* convert() shorthand for UTC.
|
||||
*
|
||||
|
@ -59,7 +66,7 @@ class DateTimeFormat
|
|||
*/
|
||||
public static function local($time, $format = self::MYSQL)
|
||||
{
|
||||
return self::convert($time, date_default_timezone_get(), 'UTC', $format);
|
||||
return self::convert($time, self::$localTimezone, 'UTC', $format);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -160,7 +167,7 @@ class DateTimeFormat
|
|||
$to_obj = new DateTimeZone('UTC');
|
||||
}
|
||||
|
||||
$d->setTimeZone($to_obj);
|
||||
$d->setTimezone($to_obj);
|
||||
|
||||
return $d->format($format);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue