class TimezoneController in Drupal 8
Same name and namespace in other branches
- 9 core/modules/system/src/Controller/TimezoneController.php \Drupal\system\Controller\TimezoneController
- 10 core/modules/system/src/Controller/TimezoneController.php \Drupal\system\Controller\TimezoneController
Provides a callback for finding out a timezone name.
Hierarchy
- class \Drupal\system\Controller\TimezoneController
Expanded class hierarchy of TimezoneController
File
- core/
modules/ system/ src/ Controller/ TimezoneController.php, line 10
Namespace
Drupal\system\ControllerView source
class TimezoneController {
/**
* Retrieve a JSON object containing a time zone name given a timezone
* abbreviation.
*
* @param string $abbreviation
* Time zone abbreviation.
* @param int $offset
* Offset from GMT in seconds. Defaults to -1 which means that first found
* time zone corresponding to abbr is returned. Otherwise exact offset is
* searched and only if not found then the first time zone with any offset
* is returned.
* @param null|bool $is_daylight_saving_time
* Daylight saving time indicator. If abbr does not exist then the time
* zone is searched solely by offset and isdst.
*
* @return \Symfony\Component\HttpFoundation\JsonResponse
* The timezone name in JsonResponse object.
*/
public function getTimezone($abbreviation = '', $offset = -1, $is_daylight_saving_time = NULL) {
// An abbreviation of "0" passed in the callback arguments should be
// interpreted as the empty string.
$abbreviation = $abbreviation ? $abbreviation : '';
$timezone = timezone_name_from_abbr($abbreviation, intval($offset), $is_daylight_saving_time);
return new JsonResponse($timezone);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
TimezoneController:: |
public | function | Retrieve a JSON object containing a time zone name given a timezone abbreviation. |