[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/classes/ -> date.php (summary)

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: 556 lines (21 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

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()


Class: core_date  - X-Ref

Core date and time related code.

get_list_of_timezones($currentvalue = null, $include99 = false)   X-Ref
Returns a localised list of timezones.

param: string $currentvalue
param: bool $include99 should the server timezone info be included?
return: array

get_localised_timezone($tz)   X-Ref
Returns localised timezone name.

param: string $tz
return: string

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.

param: int|string|float|DateTimeZone $tz
return: string timezone compatible with PHP

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?

param: mixed $userorforcedtz user object or legacy forced timezone string or tz object
return: string normalised timezone name compatible with PHP

get_user_timezone_object($userorforcedtz = null)   X-Ref
Return user timezone object.

param: mixed $userorforcedtz
return: DateTimeZone

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.




Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1