| Conditions | 3 |
| Paths | 3 |
| Total Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | public function expand($values) { |
||
| 16 | $siteTimezone = new \DateTimeZone(\Drupal::config('system.date')->get('timezone.default')); |
||
| 17 | $storageTimezone = new \DateTimeZone(DateTimeItemInterface::STORAGE_TIMEZONE); |
||
| 18 | foreach ($values as $key => $value) { |
||
| 19 | if (strpos($value, "relative:") !== FALSE) { |
||
| 20 | $relative = trim(str_replace('relative:', '', $value)); |
||
| 21 | // Get time, convert to ISO 8601 date in GMT/UTC, remove TZ offset. |
||
| 22 | $values[$key] = substr(gmdate('c', strtotime($relative)), 0, 19); |
||
| 23 | } |
||
| 24 | else { |
||
| 25 | // A Drupal install has a default site timezone, but nonetheless |
||
| 26 | // uses UTC for internal storage. If no timezone is specified in a date |
||
| 27 | // field value by the step author, assume the default timezone of |
||
| 28 | // the Drupal install, and therefore transform it into UTC for storage. |
||
| 29 | $date = new \DateTime($value, $siteTimezone); |
||
| 30 | $date->setTimezone($storageTimezone); |
||
| 31 | $values[$key] = $date->format('Y-m-d\TH:i:s'); |
||
| 32 | } |
||
| 33 | } |
||
| 34 | return $values; |
||
| 35 | } |
||
| 36 | |||
| 38 |