Differences Between: [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]
Core date and time related code.
Author: | Petr Skoda <petr.skoda@totaralms.com> |
Copyright: | 2015 Totara Learning Solutions Ltd {@link http://www.totaralms.com/} |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 695 lines (29 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
core_date:: (13 methods):
get_list_of_timezones()
get_localised_timezone()
normalise_timezone()
get_server_timezone()
get_server_timezone_object()
set_default_server_timezone()
get_user_timezone()
get_user_timezone_object()
get_default_php_timezone()
store_default_php_timezone()
phpunit_override_default_php_timezone()
phpunit_reset()
init_zones()
get_list_of_timezones($currentvalue = null, $include99 = false) X-Ref |
Returns a localised list of timezones. return: array param: string $currentvalue param: bool $include99 should the server timezone info be included? |
get_localised_timezone($tz) X-Ref |
Returns localised timezone name. return: string param: string $tz |
normalise_timezone($tz) X-Ref |
Normalise the timezone name. If timezone not supported this method falls back to server timezone (if valid) or default PHP timezone. return: string timezone compatible with PHP param: int|string|float|DateTimeZone $tz |
get_server_timezone() X-Ref |
Returns server timezone. return: string normalised timezone name compatible with PHP |
get_server_timezone_object() X-Ref |
Returns server timezone. return: DateTimeZone |
set_default_server_timezone() X-Ref |
Set PHP default timezone to $CFG->timezone. |
get_user_timezone($userorforcedtz = null) X-Ref |
Returns user timezone. Ideally the parameter should be a real user record, unfortunately the legacy code is using 99 for both server and default value. Example of using legacy API: // Date for other user via legacy API. $datestr = userdate($time, core_date::get_user_timezone($user)); The coding style rules in Moodle are moronic, why cannot the parameter names have underscores in them? return: string normalised timezone name compatible with PHP param: mixed $userorforcedtz user object or legacy forced timezone string or tz object |
get_user_timezone_object($userorforcedtz = null) X-Ref |
Return user timezone object. return: DateTimeZone param: mixed $userorforcedtz |
get_default_php_timezone() X-Ref |
Return default timezone set in php.ini or config.php. return: string normalised timezone compatible with PHP |
store_default_php_timezone() X-Ref |
To be called from lib/setup.php only! |
phpunit_override_default_php_timezone($tz) X-Ref |
Do not use directly - use $this->setTimezone('xx', $tz) instead in your test case. param: string $tz valid timezone name |
phpunit_reset() X-Ref |
To be called from phpunit reset only, after restoring $CFG. |
init_zones() X-Ref |
Initialise timezone arrays, call before use. |