Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / system / src / Controller / TimezoneController.php
1 <?php
2
3 namespace Drupal\system\Controller;
4
5 use Symfony\Component\HttpFoundation\JsonResponse;
6
7 /**
8  * Provides a callback for finding out a timezone name.
9  */
10 class TimezoneController {
11
12   /**
13    * Retrieve a JSON object containing a time zone name given a timezone
14    * abbreviation.
15    *
16    * @param string $abbreviation
17    *   Time zone abbreviation.
18    * @param int $offset
19    *   Offset from GMT in seconds. Defaults to -1 which means that first found
20    *   time zone corresponding to abbr is returned. Otherwise exact offset is
21    *   searched and only if not found then the first time zone with any offset
22    *   is returned.
23    * @param null|bool $is_daylight_saving_time
24    *   Daylight saving time indicator. If abbr does not exist then the time
25    *   zone is searched solely by offset and isdst.
26    *
27    * @return \Symfony\Component\HttpFoundation\JsonResponse
28    *   The timezone name in JsonResponse object.
29    */
30   public function getTimezone($abbreviation = '', $offset = -1, $is_daylight_saving_time = NULL) {
31     // An abbreviation of "0" passed in the callback arguments should be
32     // interpreted as the empty string.
33     $abbreviation = $abbreviation ? $abbreviation : '';
34     $timezone = timezone_name_from_abbr($abbreviation, intval($offset), $is_daylight_saving_time);
35     return new JsonResponse($timezone);
36   }
37
38 }