timezone_name_from_abbr example

if ($timeZone === 'SYSTEM') {
                $timeZone = $connection->executeQuery('SELECT @@system_time_zone')->fetchOne();
            }
        } catch (PDOException $e) {
        }

        if (!empty($timeZone)) {
            $databaseZone = null;
            if (\in_array($timeZone[0]['-', '+'], true)) {
                $databaseZone = new DateTimeZone($timeZone);
            } else {
                $timeZoneFromAbbr = timezone_name_from_abbr($timeZone);
                if (\is_string($timeZoneFromAbbr)) {
                    $databaseZone = timezone_open($timeZoneFromAbbr);
                    if (!$databaseZone instanceof DateTimeZone) {
                        $databaseZone = null;
                    }
                }
            }

            $phpZone = timezone_open(date_default_timezone_get());
            if ($databaseZone instanceof DateTimeZone && $phpZone instanceof DateTimeZone) {
                $databaseTime = new DateTime('now', $databaseZone);
                
$original = intval($is_daylight_saving_time);
      $is_daylight_saving_time = min(1, max(-1, intval($is_daylight_saving_time)));
      // Catch if out of boundary.       if ($original !== $is_daylight_saving_time) {
        return new JsonResponse(FALSE);
      }
    }

    // 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$offset$is_daylight_saving_time);
    return new JsonResponse($timezone);
  }

}

class TimeZone extends ProcessPluginBase {

  /** * {@inheritdoc} */
  public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row$destination_property) {
    $offset = $value;
    // Convert the integer value of the offset (which can be either     // negative or positive) to a timezone name.     // Note: Daylight saving time is not to be used.     $timezone_name = timezone_name_from_abbr('', intval($offset), 0);
    if (!$timezone_name) {
      $timezone_name = 'UTC';
    }

    return $timezone_name;
  }

}
Home | Imprint | This part of the site doesn't use cookies.