当前位置: 首页>>代码示例>>PHP>>正文


PHP system_time_zones函数代码示例

本文整理汇总了PHP中system_time_zones函数的典型用法代码示例。如果您正苦于以下问题:PHP system_time_zones函数的具体用法?PHP system_time_zones怎么用?PHP system_time_zones使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了system_time_zones函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * {@inheritdoc}
  */
 public function __construct(array $configuration, $plugin_id, array $plugin_definition)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition);
     if (!isset(static::$timezones)) {
         static::$timezones = system_time_zones();
     }
 }
开发者ID:scratch,项目名称:gai,代码行数:10,代码来源:UserUpdate7002.php

示例2: buildOptionsForm

 /**
  * Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::buildOptionsForm().
  */
 public function buildOptionsForm(&$form, &$form_state)
 {
     $form['label'] = array('#type' => 'textfield', '#title' => t('Label'), '#default_value' => isset($this->options['label']) ? $this->options['label'] : '', '#description' => t('The label for this field that will be displayed to end users if the style requires it.'));
     $form['gcal'] = array('#type' => 'textfield', '#title' => t('Feed URL'), '#maxlength' => 1024, '#default_value' => $this->options['gcal']);
     $form['class'] = array('#type' => 'textfield', '#title' => t('CSS class'), '#default_value' => $this->options['class']);
     $form['timezone'] = array('#type' => 'select', '#title' => t('Time zone'), '#default_value' => $this->options['timezone'], '#options' => system_time_zones(), '#attributes' => array('class' => array('timezone-detect')));
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:10,代码来源:GoogleCalendar.php

示例3: buildOptionsForm

 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     $date_formats = array();
     foreach ($this->dateFormatStorage->loadMultiple() as $machine_name => $value) {
         $date_formats[$machine_name] = $this->t('@name format: @date', array('@name' => $value->label(), '@date' => $this->dateFormatter->format(REQUEST_TIME, $machine_name)));
     }
     $form['date_format'] = array('#type' => 'select', '#title' => $this->t('Date format'), '#options' => $date_formats + array('custom' => $this->t('Custom'), 'raw time ago' => $this->t('Time ago'), 'time ago' => $this->t('Time ago (with "ago" appended)'), 'raw time hence' => $this->t('Time hence'), 'time hence' => $this->t('Time hence (with "hence" appended)'), 'raw time span' => $this->t('Time span (future dates have "-" prepended)'), 'inverse time span' => $this->t('Time span (past dates have "-" prepended)'), 'time span' => $this->t('Time span (with "ago/hence" appended)')), '#default_value' => isset($this->options['date_format']) ? $this->options['date_format'] : 'small');
     $form['custom_date_format'] = array('#type' => 'textfield', '#title' => $this->t('Custom date format'), '#description' => $this->t('If "Custom", see <a href="http://us.php.net/manual/en/function.date.php" target="_blank">the PHP docs</a> for date formats. Otherwise, enter the number of different time units to display, which defaults to 2.'), '#default_value' => isset($this->options['custom_date_format']) ? $this->options['custom_date_format'] : '');
     // Setup #states for all possible date_formats on the custom_date_format form element.
     foreach (array('custom', 'raw time ago', 'time ago', 'raw time hence', 'time hence', 'raw time span', 'time span', 'raw time span', 'inverse time span', 'time span') as $custom_date_possible) {
         $form['custom_date_format']['#states']['visible'][] = array(':input[name="options[date_format]"]' => array('value' => $custom_date_possible));
     }
     $form['timezone'] = array('#type' => 'select', '#title' => $this->t('Timezone'), '#description' => $this->t('Timezone to be used for date output.'), '#options' => array('' => $this->t('- Default site/user timezone -')) + system_time_zones(FALSE), '#default_value' => $this->options['timezone']);
     foreach (array_merge(array('custom'), array_keys($date_formats)) as $timezone_date_formats) {
         $form['timezone']['#states']['visible'][] = array(':input[name="options[date_format]"]' => array('value' => $timezone_date_formats));
     }
     parent::buildOptionsForm($form, $form_state);
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:18,代码来源:Date.php

示例4: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $countries = $this->countryManager->getList();
     $system_date = $this->config('system.date');
     // Date settings:
     $zones = system_time_zones();
     $form['locale'] = array('#type' => 'details', '#title' => t('Locale'), '#open' => TRUE);
     $form['locale']['site_default_country'] = array('#type' => 'select', '#title' => t('Default country'), '#empty_value' => '', '#default_value' => $system_date->get('country.default'), '#options' => $countries, '#attributes' => array('class' => array('country-detect')));
     $form['locale']['date_first_day'] = array('#type' => 'select', '#title' => t('First day of week'), '#default_value' => $system_date->get('first_day'), '#options' => array(0 => t('Sunday'), 1 => t('Monday'), 2 => t('Tuesday'), 3 => t('Wednesday'), 4 => t('Thursday'), 5 => t('Friday'), 6 => t('Saturday')));
     $form['timezone'] = array('#type' => 'details', '#title' => t('Time zones'), '#open' => TRUE);
     $form['timezone']['date_default_timezone'] = array('#type' => 'select', '#title' => t('Default time zone'), '#default_value' => $system_date->get('timezone.default') ?: date_default_timezone_get(), '#options' => $zones);
     $configurable_timezones = $system_date->get('timezone.user.configurable');
     $form['timezone']['configurable_timezones'] = array('#type' => 'checkbox', '#title' => t('Users may set their own time zone'), '#default_value' => $configurable_timezones);
     $form['timezone']['configurable_timezones_wrapper'] = array('#type' => 'container', '#states' => array('invisible' => array('input[name="configurable_timezones"]' => array('checked' => FALSE))));
     $form['timezone']['configurable_timezones_wrapper']['empty_timezone_message'] = array('#type' => 'checkbox', '#title' => t('Remind users at login if their time zone is not set'), '#default_value' => $system_date->get('timezone.user.warn'), '#description' => t('Only applied if users may set their own time zone.'));
     $form['timezone']['configurable_timezones_wrapper']['user_default_timezone'] = array('#type' => 'radios', '#title' => t('Time zone for new users'), '#default_value' => $system_date->get('timezone.user.default'), '#options' => array(DRUPAL_USER_TIMEZONE_DEFAULT => t('Default time zone'), DRUPAL_USER_TIMEZONE_EMPTY => t('Empty time zone'), DRUPAL_USER_TIMEZONE_SELECT => t('Users may set their own time zone at registration')), '#description' => t('Only applied if users may set their own time zone.'));
     return parent::buildForm($form, $form_state);
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:21,代码来源:RegionalForm.php

示例5: getAllowedTimezones

 /**
  * Defines allowed timezones for the field's AllowedValues constraint.
  *
  * @return string[]
  *   The allowed values.
  */
 public static function getAllowedTimezones()
 {
     return array_keys(system_time_zones());
 }
开发者ID:ravindrasingh22,项目名称:Drupal-8-rc,代码行数:10,代码来源:User.php

示例6: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $form['#title'] = $this->t('Configure site');
     // Warn about settings.php permissions risk
     $settings_dir = $this->sitePath;
     $settings_file = $settings_dir . '/settings.php';
     // Check that $_POST is empty so we only show this message when the form is
     // first displayed, not on the next page after it is submitted. (We do not
     // want to repeat it multiple times because it is a general warning that is
     // not related to the rest of the installation process; it would also be
     // especially out of place on the last page of the installer, where it would
     // distract from the message that the Drupal installation has completed
     // successfully.)
     $post_params = $this->getRequest()->request->all();
     if (empty($post_params) && (!drupal_verify_install_file($this->root . '/' . $settings_file, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE) || !drupal_verify_install_file($this->root . '/' . $settings_dir, FILE_NOT_WRITABLE, 'dir'))) {
         drupal_set_message(t('All necessary changes to %dir and %file have been made, so you should remove write permissions to them now in order to avoid security risks. If you are unsure how to do so, consult the <a href=":handbook_url">online handbook</a>.', array('%dir' => $settings_dir, '%file' => $settings_file, ':handbook_url' => 'https://www.drupal.org/server-permissions')), 'warning');
     }
     $form['#attached']['library'][] = 'system/drupal.system';
     // Add JavaScript time zone detection.
     $form['#attached']['library'][] = 'core/drupal.timezone';
     // We add these strings as settings because JavaScript translation does not
     // work during installation.
     $form['#attached']['drupalSettings']['copyFieldValue']['edit-site-mail'] = ['edit-account-mail'];
     $form['site_information'] = array('#type' => 'fieldgroup', '#title' => $this->t('Site information'));
     $form['site_information']['site_name'] = array('#type' => 'textfield', '#title' => $this->t('Site name'), '#required' => TRUE, '#weight' => -20);
     $form['site_information']['site_mail'] = array('#type' => 'email', '#title' => $this->t('Site email address'), '#default_value' => ini_get('sendmail_from'), '#description' => $this->t("Automated emails, such as registration information, will be sent from this address. Use an address ending in your site's domain to help prevent these emails from being flagged as spam."), '#required' => TRUE, '#weight' => -15);
     $form['admin_account'] = array('#type' => 'fieldgroup', '#title' => $this->t('Site maintenance account'));
     $form['admin_account']['account']['name'] = array('#type' => 'textfield', '#title' => $this->t('Username'), '#maxlength' => USERNAME_MAX_LENGTH, '#description' => $this->t("Several special characters are allowed, including space, period (.), hyphen (-), apostrophe ('), underscore (_), and the @ sign."), '#required' => TRUE, '#attributes' => array('class' => array('username')));
     $form['admin_account']['account']['pass'] = array('#type' => 'password_confirm', '#required' => TRUE, '#size' => 25);
     $form['admin_account']['account']['#tree'] = TRUE;
     $form['admin_account']['account']['mail'] = array('#type' => 'email', '#title' => $this->t('Email address'), '#required' => TRUE);
     $form['regional_settings'] = array('#type' => 'fieldgroup', '#title' => $this->t('Regional settings'));
     $countries = $this->countryManager->getList();
     $form['regional_settings']['site_default_country'] = array('#type' => 'select', '#title' => $this->t('Default country'), '#empty_value' => '', '#default_value' => $this->config('system.date')->get('country.default'), '#options' => $countries, '#description' => $this->t('Select the default country for the site.'), '#weight' => 0);
     $form['regional_settings']['date_default_timezone'] = array('#type' => 'select', '#title' => $this->t('Default time zone'), '#default_value' => @date_default_timezone_get(), '#options' => system_time_zones(), '#description' => $this->t('By default, dates in this site will be displayed in the chosen time zone.'), '#weight' => 5, '#attributes' => array('class' => array('timezone-detect')));
     $form['update_notifications'] = array('#type' => 'fieldgroup', '#title' => $this->t('Update notifications'));
     $form['update_notifications']['update_status_module'] = array('#type' => 'checkboxes', '#title' => $this->t('Update notifications'), '#options' => array(1 => $this->t('Check for updates automatically'), 2 => $this->t('Receive email notifications')), '#default_value' => array(1, 2), '#description' => $this->t('The system will notify you when updates and important security releases are available for installed components. Anonymous information about your site is sent to <a href=":drupal">Drupal.org</a>.', array(':drupal' => 'https://www.drupal.org')), '#weight' => 15);
     $form['update_notifications']['update_status_module'][2] = array('#states' => array('visible' => array('input[name="update_status_module[1]"]' => array('checked' => TRUE))));
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Save and continue'), '#weight' => 15, '#button_type' => 'primary');
     return $form;
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:45,代码来源:SiteConfigureForm.php

示例7: install_configure_form

/**
 * Form API array definition for site configuration.
 */
function install_configure_form(&$form_state, $url)
{
    $form['intro'] = array('#markup' => st('To configure your website, please provide the following information.'), '#weight' => -10);
    $form['site_information'] = array('#type' => 'fieldset', '#title' => st('Site information'), '#collapsible' => FALSE);
    $form['site_information']['site_name'] = array('#type' => 'textfield', '#title' => st('Site name'), '#required' => TRUE, '#weight' => -20);
    $form['site_information']['site_mail'] = array('#type' => 'textfield', '#title' => st('Site e-mail address'), '#default_value' => ini_get('sendmail_from'), '#description' => st("The <em>From</em> address in automated e-mails sent during registration and new password requests, and other notifications. (Use an address ending in your site's domain to help prevent this e-mail being flagged as spam.)"), '#required' => TRUE, '#weight' => -15);
    $form['admin_account'] = array('#type' => 'fieldset', '#title' => st('Administrator account'), '#collapsible' => FALSE);
    $form['admin_account']['account']['#tree'] = TRUE;
    $form['admin_account']['markup'] = array('#markup' => '<p class="description">' . st('The administrator account has complete access to the site; it will automatically be granted all permissions and can perform any administrative activity. This will be the only account that can perform certain activities, so keep its credentials safe.') . '</p>', '#weight' => -10);
    $form['admin_account']['account']['name'] = array('#type' => 'textfield', '#title' => st('Username'), '#maxlength' => USERNAME_MAX_LENGTH, '#description' => st('Spaces are allowed; punctuation is not allowed except for periods, hyphens, and underscores.'), '#required' => TRUE, '#weight' => -10, '#attributes' => array('class' => 'username'));
    $form['admin_account']['account']['mail'] = array('#type' => 'textfield', '#title' => st('E-mail address'), '#maxlength' => EMAIL_MAX_LENGTH, '#description' => st('All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.'), '#required' => TRUE, '#weight' => -5);
    $form['admin_account']['account']['pass'] = array('#type' => 'password_confirm', '#required' => TRUE, '#size' => 25, '#weight' => 0);
    $form['server_settings'] = array('#type' => 'fieldset', '#title' => st('Server settings'), '#collapsible' => FALSE);
    $form['server_settings']['date_default_timezone'] = array('#type' => 'select', '#title' => st('Default time zone'), '#default_value' => date_default_timezone_get(), '#options' => system_time_zones(), '#description' => st('By default, dates in this site will be displayed in the chosen time zone.'), '#weight' => 5, '#attributes' => array('class' => 'timezone-detect'));
    $form['server_settings']['clean_url'] = array('#type' => 'radios', '#title' => st('Clean URLs'), '#default_value' => 0, '#options' => array(0 => st('Disabled'), 1 => st('Enabled')), '#description' => st('This option makes Drupal emit "clean" URLs (i.e. without <code>?q=</code> in the URL).'), '#disabled' => TRUE, '#prefix' => '<div id="clean-url" class="install">', '#suffix' => '</div>', '#weight' => 10);
    $form['server_settings']['update_status_module'] = array('#type' => 'checkboxes', '#title' => st('Update notifications'), '#options' => array(1 => st('Check for updates automatically')), '#default_value' => array(1), '#description' => st('With this option enabled, Drupal will notify you when new releases are available. This will significantly enhance your site\'s security and is <strong>highly recommended</strong>. This requires your site to periodically send anonymous information on its installed components to <a href="@drupal">drupal.org</a>. For more information please see the <a href="@update">update notification information</a>.', array('@drupal' => 'http://drupal.org', '@update' => 'http://drupal.org/handbook/modules/update')), '#weight' => 15);
    $form['submit'] = array('#type' => 'submit', '#value' => st('Save and continue'), '#weight' => 15);
    $form['#action'] = $url;
    $form['#redirect'] = FALSE;
    // Allow the profile to alter this form. $form_state isn't available
    // here, but to conform to the hook_form_alter() signature, we pass
    // an empty array.
    $hook_form_alter = $_GET['profile'] . '_form_alter';
    if (function_exists($hook_form_alter)) {
        $hook_form_alter($form, array(), 'install_configure');
    }
    return $form;
}
开发者ID:schuyler1d,项目名称:drupal,代码行数:31,代码来源:install.php

示例8: _install_configure_form

/**
 * Form API array definition for site configuration.
 */
function _install_configure_form($form, &$form_state, &$install_state)
{
    include_once DRUPAL_ROOT . '/includes/locale.inc';
    $form['site_information'] = array('#type' => 'fieldset', '#title' => st('Site information'), '#collapsible' => FALSE);
    $form['site_information']['site_name'] = array('#type' => 'textfield', '#title' => st('Site name'), '#required' => TRUE, '#weight' => -20);
    $form['site_information']['site_mail'] = array('#type' => 'textfield', '#title' => st('Site e-mail address'), '#default_value' => ini_get('sendmail_from'), '#description' => st("Automated e-mails, such as registration information, will be sent from this address. Use an address ending in your site's domain to help prevent these e-mails from being flagged as spam."), '#required' => TRUE, '#weight' => -15);
    $form['admin_account'] = array('#type' => 'fieldset', '#title' => st('Site maintenance account'), '#collapsible' => FALSE);
    $form['admin_account']['account']['#tree'] = TRUE;
    $form['admin_account']['account']['name'] = array('#type' => 'textfield', '#title' => st('Username'), '#maxlength' => USERNAME_MAX_LENGTH, '#description' => st('Spaces are allowed; punctuation is not allowed except for periods, hyphens, and underscores.'), '#required' => TRUE, '#weight' => -10, '#attributes' => array('class' => array('username')));
    $form['admin_account']['account']['mail'] = array('#type' => 'textfield', '#title' => st('E-mail address'), '#maxlength' => EMAIL_MAX_LENGTH, '#required' => TRUE, '#weight' => -5);
    $form['admin_account']['account']['pass'] = array('#type' => 'password_confirm', '#required' => TRUE, '#size' => 25, '#weight' => 0);
    $form['server_settings'] = array('#type' => 'fieldset', '#title' => st('Server settings'), '#collapsible' => FALSE);
    $countries = country_get_list();
    $countries = array_merge(array('' => st('No default country')), $countries);
    $form['server_settings']['site_default_country'] = array('#type' => 'select', '#title' => t('Default country'), '#default_value' => variable_get('site_default_country', ''), '#options' => $countries, '#description' => st('Select the default country for the site.'), '#weight' => 0);
    $form['server_settings']['date_default_timezone'] = array('#type' => 'select', '#title' => st('Default time zone'), '#default_value' => date_default_timezone_get(), '#options' => system_time_zones(), '#description' => st('By default, dates in this site will be displayed in the chosen time zone.'), '#weight' => 5, '#attributes' => array('class' => array('timezone-detect')));
    $form['server_settings']['clean_url'] = array('#type' => 'hidden', '#default_value' => 0, '#attributes' => array('class' => array('install')));
    $form['update_notifications'] = array('#type' => 'fieldset', '#title' => st('Update notifications'), '#collapsible' => FALSE);
    $form['update_notifications']['update_status_module'] = array('#type' => 'checkboxes', '#options' => array(1 => st('Check for updates automatically'), 2 => st('Receive e-mail notifications')), '#default_value' => array(1, 2), '#description' => st('The system will notify you when updates and important security releases are available for installed components. Anonymous information about your site is sent to <a href="@drupal">Drupal.org</a>.', array('@drupal' => 'http://drupal.org')), '#weight' => 15);
    $form['submit'] = array('#type' => 'submit', '#value' => st('Save and continue'), '#weight' => 15);
    // Allow the profile to alter this form. $form_state isn't available
    // here, but to conform to the hook_form_alter() signature, we pass
    // an empty array.
    $hook_form_alter = $install_state['parameters']['profile'] . '_form_alter';
    if (function_exists($hook_form_alter)) {
        $hook_form_alter($form, array(), 'install_configure');
    }
    return $form;
}
开发者ID:blipp,项目名称:drupal,代码行数:32,代码来源:install.php

示例9: settingsForm

 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $form = parent::settingsForm($form, $form_state);
     $form['timezone_override'] = array('#type' => 'select', '#title' => $this->t('Time zone override'), '#description' => $this->t('The time zone selected here will always be used'), '#options' => system_time_zones(TRUE), '#default_value' => $this->getSetting('timezone_override'));
     return $form;
 }
开发者ID:sarahwillem,项目名称:OD8,代码行数:9,代码来源:DateTimeFormatterBase.php

示例10: settingsForm

 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $elements = parent::settingsForm($form, $form_state);
     $date_formats = array();
     foreach ($this->dateFormatStorage->loadMultiple() as $machine_name => $value) {
         $date_formats[$machine_name] = $this->t('@name format: @date', array('@name' => $value->label(), '@date' => $this->dateFormatter->format(REQUEST_TIME, $machine_name)));
     }
     $date_formats['custom'] = $this->t('Custom');
     $elements['date_format'] = array('#type' => 'select', '#title' => $this->t('Date format'), '#options' => $date_formats, '#default_value' => $this->getSetting('date_format') ?: 'medium');
     $elements['custom_date_format'] = array('#type' => 'textfield', '#title' => $this->t('Custom date format'), '#description' => $this->t('See <a href="@url" target="_blank">the documentation for PHP date formats</a>.', ['@url' => 'http://php.net/manual/function.date.php']), '#default_value' => $this->getSetting('custom_date_format') ?: '');
     $elements['custom_date_format']['#states']['visible'][] = array(':input[name="options[settings][date_format]"]' => array('value' => 'custom'));
     $elements['timezone'] = array('#type' => 'select', '#title' => $this->t('Time zone'), '#options' => array('' => $this->t('- Default site/user time zone -')) + system_time_zones(FALSE), '#default_value' => $this->getSetting('timezone'));
     return $elements;
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:17,代码来源:TimestampFormatter.php

示例11: parse_date

 /**
  * Parses a ical date element.
  *
  * Possible formats to parse include:
  *   PROPERTY:YYYYMMDD[T][HH][MM][SS][Z]
  *   PROPERTY;VALUE=DATE:YYYYMMDD[T][HH][MM][SS][Z]
  *   PROPERTY;VALUE=DATE-TIME:YYYYMMDD[T][HH][MM][SS][Z]
  *   PROPERTY;TZID=XXXXXXXX;VALUE=DATE:YYYYMMDD[T][HH][MM][SS]
  *   PROPERTY;TZID=XXXXXXXX:YYYYMMDD[T][HH][MM][SS]
  *
  *   The property and the colon before the date are removed in the import
  *   process above and we are left with $field and $data.
  *
  * @param string $field
  *   The text before the colon and the date, i.e.
  *   ';VALUE=DATE:', ';VALUE=DATE-TIME:', ';TZID='
  * @param string $data
  *   The date itself, after the colon, in the format YYYYMMDD[T][HH][MM][SS][Z]
  *   'Z', if supplied, means the date is in UTC.
  *
  * @return array
  *   $items array, consisting of:
  *      'datetime'   => date in YYYY-MM-DD HH:MM format, not timezone adjusted
  *      'all_day'    => whether this is an all-day event with no time
  *      'tz'         => the timezone of the date, could be blank if the ical
  *                      has no timezone; the ical specs say no timezone
  *                      conversion should be done if no timezone info is
  *                      supplied
  *  @todo
  *   Another option for dates is the format PROPERTY;VALUE=PERIOD:XXXX. The
  *   period may include a duration, or a date and a duration, or two dates, so
  *   would have to be split into parts and run through date_ical_parse_date()
  *   and date_ical_parse_duration(). This is not commonly used, so ignored for
  *   now. It will take more work to figure how to support that.
  */
 public static function parse_date($data, $field = 'DATE:')
 {
     $items = array('datetime' => '', 'all_day' => '', 'tz' => '');
     if (empty($data)) {
         return $items;
     }
     // Make this a little more whitespace independent.
     $data = trim($data);
     // Turn the properties into a nice indexed array of
     // array(PROPERTYNAME => PROPERTYVALUE);
     $field_parts = preg_split('/[;:]/', $field);
     $properties = array();
     foreach ($field_parts as $part) {
         if (strpos($part, '=') !== FALSE) {
             $tmp = explode('=', $part);
             $properties[$tmp[0]] = $tmp[1];
         }
     }
     // Make this a little more whitespace independent.
     $data = trim($data);
     // Record if a time has been found.
     $has_time = FALSE;
     // If a format is specified, parse it according to that format.
     if (isset($properties['VALUE'])) {
         switch ($properties['VALUE']) {
             case 'DATE':
                 preg_match(self::$regex_ical_date, $data, $regs);
                 // Date.
                 $datetime = DrupalDateTime::datePad($regs[1]) . '-' . DrupalDateTime::datePad($regs[2]) . '-' . DrupalDateTime::datePad($regs[3]);
                 break;
             case 'DATE-TIME':
                 preg_match(self::$regex_ical_datetime, $data, $regs);
                 // Date.
                 $datetime = DrupalDateTime::datePad($regs[1]) . '-' . DrupalDateTime::datePad($regs[2]) . '-' . DrupalDateTime::datePad($regs[3]);
                 // Time.
                 $datetime .= ' ' . DrupalDateTime::datePad($regs[4]) . ':' . DrupalDateTime::datePad($regs[5]) . ':' . DrupalDateTime::datePad($regs[6]);
                 $has_time = TRUE;
                 break;
         }
     } else {
         preg_match(self::$regex_loose, $data, $regs);
         if (!empty($regs) && count($regs) > 2) {
             // Date.
             $datetime = DrupalDateTime::datePad($regs[1]) . '-' . DrupalDateTime::datePad($regs[2]) . '-' . DrupalDateTime::datePad($regs[3]);
             if (isset($regs[4])) {
                 $has_time = TRUE;
                 // Time.
                 $datetime .= ' ' . (!empty($regs[5]) ? DrupalDateTime::datePad($regs[5]) : '00') . ':' . (!empty($regs[6]) ? DrupalDateTime::datePad($regs[6]) : '00') . ':' . (!empty($regs[7]) ? DrupalDateTime::datePad($regs[7]) : '00');
             }
         }
     }
     // Use timezone if explicitly declared.
     if (isset($properties['TZID'])) {
         $tz = $properties['TZID'];
         // Fix alternatives like US-Eastern which should be US/Eastern.
         $tz = str_replace('-', '/', $tz);
         // Unset invalid timezone names.
         module_load_include('inc', 'date_api', 'date_api.admin');
         $tz = _date_timezone_replacement($tz);
         if (!in_array($tz, array_keys(system_time_zones()))) {
             $tz = '';
         }
     } elseif (strpos($data, 'Z') !== FALSE) {
         $tz = 'UTC';
     } else {
//.........这里部分代码省略.........
开发者ID:darrylri,项目名称:protovbmwmo,代码行数:101,代码来源:DateiCalParse.php


注:本文中的system_time_zones函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。