Updated Drupal to 8.6. This goes with the following updates because it's possible...
[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   /**
19    * {@inheritdoc}
20    */
21   public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
22     $offset = $value;
23     // Convert the integer value of the offset (which can be either
24     // negative or positive) to a timezone name.
25     // Note: Daylight saving time is not to be used.
26     $timezone_name = timezone_name_from_abbr('', intval($offset), 0);
27     if (!$timezone_name) {
28       $timezone_name = 'UTC';
29     }
30
31     return $timezone_name;
32   }
33
34 }