예제 #1
0
 /**
  * Sets the proper time zone on a DrupalDateTime object for the current user.
  *
  * A DrupalDateTime object loaded from the database will have the UTC time
  * zone applied to it.  This method will apply the time zone for the current
  * user, based on system and user settings.
  *
  * @see drupal_get_user_timezone()
  *
  * @param \Drupal\Core\Datetime\DrupalDateTime $date
  *   A DrupalDateTime object.
  */
 protected function setTimeZone(DrupalDateTime $date)
 {
     $date->setTimeZone(timezone_open(drupal_get_user_timezone()));
 }
예제 #2
0
 /**
  * Sets the proper time zone on a DrupalDateTime object for the current user.
  *
  * A DrupalDateTime object loaded from the database will have the UTC time
  * zone applied to it.  This method will apply the time zone for the current
  * user, based on system and user settings.
  *
  * @see drupal_get_user_timezone()
  *
  * @param \Drupal\Core\Datetime\DrupalDateTime $date
  *   A DrupalDateTime object.
  */
 protected function setTimeZone(DrupalDateTime $date)
 {
     if ($this->getFieldSetting('datetime_type') === DateTimeItem::DATETIME_TYPE_DATE) {
         // A date without time has no timezone conversion.
         $timezone = DATETIME_STORAGE_TIMEZONE;
     } else {
         $timezone = drupal_get_user_timezone();
     }
     $date->setTimeZone(timezone_open($timezone));
 }