3dc88810d5756f316c128285581017f37a4bafb7
[yaffs-website] / web / core / modules / system / src / Plugin / migrate / process / d6 / TimeZone.php
1 <?php
2
3 namespace Drupal\system\Plugin\migrate\process\d6;
4
5 use Drupal\migrate\MigrateExecutableInterface;
6 use Drupal\migrate\ProcessPluginBase;
7 use Drupal\migrate\Row;
8
9 /**
10  * Process the D6 Timezone offset into a D8 compatible timezone name.
11  *
12  * @MigrateProcessPlugin(
13  *   id = "timezone"
14  * )
15  */
16 class TimeZone extends ProcessPluginBase {
17   /**
18    * {@inheritdoc}
19    */
20   public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
21     $offset = $value;
22     // Convert the integer value of the offset (which can be either
23     // negative or positive) to a timezone name.
24     // Note: Daylight saving time is not to be used.
25     $timezone_name = timezone_name_from_abbr('', intval($offset), 0);
26     if (!$timezone_name) {
27       $timezone_name = 'UTC';
28     }
29
30     return $timezone_name;
31   }
32
33 }