Commit 949e7fe6 authored by catch's avatar catch

Issue #2276183 by alexpott: Fixed Date intl support is broken, remove it.

parent a71080e6
......@@ -68,7 +68,7 @@ text:
# PHP Date format string that is translatable.
date_format:
type: string
label: 'PHP date format'
label: 'Date format'
translatable: true
# HTML color value.
......
......@@ -708,30 +708,6 @@ function _format_date_callback(array $matches = NULL, $new_langcode = NULL) {
return $cache[$langcode][$code][$string];
}
/**
* Retrieves the correct datetime format type for this system.
*
* This value is sometimes required when the format type needs to be determined
* before a date can be created.
*
* @return string
* A string as defined in \DrupalComponent\Datetime\DateTimePlus.php: either
* 'intl' or 'php', depending on whether IntlDateFormatter is available.
*/
function datetime_default_format_type() {
static $drupal_static_fast;
if (!isset($drupal_static_fast)) {
$drupal_static_fast['format_type'] = &drupal_static(__FUNCTION__);
}
$format_type = &$drupal_static_fast['format_type'];
if (!isset($format_type)) {
$date = new DrupalDateTime();
$format_type = $date->canUseIntl() ? DrupalDateTime::INTL : DrupalDateTime::PHP;
}
return $format_type;
}
/**
* @} End of "defgroup format".
*/
......
......@@ -142,23 +142,19 @@ public function format($timestamp, $type = 'medium', $format = '', $timezone = N
);
$date = DrupalDateTime::createFromTimestamp($timestamp, $this->timezones[$timezone], $create_settings);
// Find the appropriate format type.
$key = $date->canUseIntl() ? DrupalDateTime::INTL : DrupalDateTime::PHP;
// If we have a non-custom date format use the provided date format pattern.
if ($date_format = $this->dateFormat($type, $langcode)) {
$format = $date_format->getPattern($key);
$format = $date_format->getPattern();
}
// Fall back to medium if a format was not found.
if (empty($format)) {
$format = $this->dateFormat('fallback', $langcode)->getPattern($key);
$format = $this->dateFormat('fallback', $langcode)->getPattern();
}
// Call $date->format().
$settings = array(
'langcode' => $langcode,
'format_string_type' => $key,
);
return Xss::filter($date->format($format, $settings));
}
......
......@@ -37,29 +37,16 @@ class DrupalDateTime extends DateTimePlus {
* possible to a validation step to confirm that the date created
* from a format string exactly matches the input. This option
* indicates the format can be used for validation. Defaults to TRUE.
* - langcode: (optional) String two letter language code to construct
* the locale string by the intlDateFormatter class. Used to control
* the result of the format() method if that class is available.
* - langcode: (optional) Used to control the result of the format() method.
* Defaults to NULL.
* - country: (optional) String two letter country code to construct
* the locale string by the intlDateFormatter class. Used to control
* the result of the format() method if that class is available.
* Defaults to NULL.
* - calendar: (optional) String calendar name to use for the date.
* Defaults to DateTimePlus::CALENDAR.
* - debug: (optional) Boolean choice to leave debug values in the
* date object for debugging purposes. Defaults to FALSE.
*/
public function __construct($time = 'now', $timezone = NULL, $settings = array()) {
// We can set the langcode and country using Drupal values.
if (!isset($settings['langcode'])) {
$settings['langcode'] = \Drupal::languageManager()->getCurrentLanguage()->id;
}
if (!isset($settings['country'])) {
$settings['country'] = \Drupal::config('system.date')->get('country.default');
}
// Instantiate the parent class.
parent::__construct($time, $timezone, $settings);
......@@ -82,75 +69,37 @@ protected function prepareTimezone($timezone) {
/**
* Overrides format().
*
* Uses the IntlDateFormatter to display the format, if possible.
* Adds an optional array of settings that provides the information
* the IntlDateFormatter will need.
*
* @param string $format
* A format string using either PHP's date() or the
* IntlDateFormatter() format.
* A format string using either PHP's date().
* @param array $settings
* - format_string_type: (optional) DateTimePlus::PHP or
* DateTimePlus::INTL. Identifies the pattern used by the format
* string. When using the Intl formatter, the format string must
* use the Intl pattern, which is different from the pattern used
* by the DateTime format function. Defaults to DateTimePlus::PHP.
* - timezone: (optional) String timezone name. Defaults to the timezone
* of the date object.
* - langcode: (optional) String two letter language code to construct the
* locale string by the intlDateFormatter class. Used to control the
* result of the format() method if that class is available. Defaults
* to NULL.
* - country: (optional) String two letter country code to construct the
* locale string by the intlDateFormatter class. Used to control the
* result of the format() method if that class is available. Defaults
* to NULL.
* - calendar: (optional) String calendar name to use for the date,
* Defaults to DateTimePlus::CALENDAR.
* - date_type: (optional) Integer date type to use in the formatter,
* defaults to IntlDateFormatter::FULL.
* - time_type: (optional) Integer date type to use in the formatter,
* defaults to IntlDateFormatter::FULL.
* - lenient: (optional) Boolean choice of whether or not to use lenient
* processing in the intl formatter. Defaults to FALSE;
* - langcode: (optional) String two letter language code used to control
* the result of the format() method. Defaults to NULL.
*
* @return string
* The formatted value of the date.
*/
public function format($format, $settings = array()) {
$settings['format_string_type'] = isset($settings['format_string_type']) ? $settings['format_string_type'] : static::PHP;
$settings['calendar'] = !empty($settings['calendar']) ? $settings['calendar'] : $this->calendar;
$settings['langcode'] = !empty($settings['langcode']) ? $settings['langcode'] : $this->langcode;
$settings['country'] = !empty($settings['country']) ? $settings['country'] : $this->country;
// Format the date and catch errors.
try {
// If we have what we need to use the IntlDateFormatter, do so.
if ($this->canUseIntl($settings['calendar'], $settings['langcode'], $settings['country']) && $settings['format_string_type'] == parent::INTL) {
$value = parent::format($format, $settings);
}
// Otherwise, use the default Drupal method.
else {
// Encode markers that should be translated. 'A' becomes
// '\xEF\AA\xFF'. xEF and xFF are invalid UTF-8 sequences,
// and we assume they are not in the input string.
// Paired backslashes are isolated to prevent errors in
// read-ahead evaluation. The read-ahead expression ensures that
// A matches, but not \A.
$format = preg_replace(array('/\\\\\\\\/', '/(?<!\\\\)([AaeDlMTF])/'), array("\xEF\\\\\\\\\xFF", "\xEF\\\\\$1\$1\xFF"), $format);
// Call date_format().
$format = parent::format($format);
// Pass the langcode to _format_date_callback().
_format_date_callback(NULL, $settings['langcode']);
// Translate the marked sequences.
$value = preg_replace_callback('/\xEF([AaeDlMTF]?)(.*?)\xFF/', '_format_date_callback', $format);
}
// Encode markers that should be translated. 'A' becomes
// '\xEF\AA\xFF'. xEF and xFF are invalid UTF-8 sequences,
// and we assume they are not in the input string.
// Paired backslashes are isolated to prevent errors in
// read-ahead evaluation. The read-ahead expression ensures that
// A matches, but not \A.
$format = preg_replace(array('/\\\\\\\\/', '/(?<!\\\\)([AaeDlMTF])/'), array("\xEF\\\\\\\\\xFF", "\xEF\\\\\$1\$1\xFF"), $format);
// Call date_format().
$format = parent::format($format);
// Pass the langcode to _format_date_callback().
_format_date_callback(NULL, $settings['langcode']);
// Translate the marked sequences.
$value = preg_replace_callback('/\xEF([AaeDlMTF]?)(.*?)\xFF/', '_format_date_callback', $format);
}
catch (\Exception $e) {
$this->errors[] = $e->getMessage();
......
......@@ -23,12 +23,7 @@ class DateFormat implements ElementInterface {
* {@inheritdoc}
*/
public function getFormElement(array $definition, Language $language, $value) {
if (class_exists('intlDateFormatter')) {
$description = $this->t('A user-defined date format. See the <a href="@url">PHP manual</a> for available options.', array('@url' => 'http://userguide.icu-project.org/formatparse/datetime'));
}
else {
$description = $this->t('A user-defined date format. See the <a href="@url">PHP manual</a> for available options.', array('@url' => 'http://php.net/manual/function.date.php'));
}
$description = $this->t('A user-defined date format. See the <a href="@url">PHP manual</a> for available options.', array('@url' => 'http://php.net/manual/function.date.php'));
$format = $this->t('Displayed as %date_format', array('%date_format' => \Drupal::service('date')->format(REQUEST_TIME, 'custom', $value)));
return array(
'#type' => 'textfield',
......
......@@ -403,7 +403,7 @@ public function testDateFormatTranslation() {
// Update translatable fields.
$edit = array(
'config_names[system.date_format.' . $id . '][label][translation]' => $id . ' - FR',
'config_names[system.date_format.' . $id . '][pattern][pattern.php][translation]' => 'D',
'config_names[system.date_format.' . $id . '][pattern][translation]' => 'D',
);
// Save language specific version of form.
......@@ -413,7 +413,7 @@ public function testDateFormatTranslation() {
$override = \Drupal::languageManager()->getLanguageConfigOverride('fr', 'system.date_format.' . $id);
$expected = array(
'label' => $id . ' - FR',
'pattern' => array('php' => 'D'),
'pattern' => 'D',
);
$this->assertEqual($expected, $override->get());
......
......@@ -30,17 +30,15 @@
* Implements hook_element_info().
*/
function datetime_element_info() {
$format_type = datetime_default_format_type();
$date_format = '';
$time_format = '';
// Date formats cannot be loaded during install or update.
if (!defined('MAINTENANCE_MODE')) {
if ($date_format_entity = entity_load('date_format', 'html_date')) {
$date_format = $date_format_entity->getPattern($format_type);
$date_format = $date_format_entity->getPattern();
}
if ($time_format_entity = entity_load('date_format', 'html_time')) {
$time_format = $time_format_entity->getPattern($format_type);
$time_format = $time_format_entity->getPattern();
}
}
$types['datetime'] = array(
......@@ -51,7 +49,6 @@ function datetime_element_info() {
'#theme' => 'datetime_form',
'#theme_wrappers' => array('datetime_wrapper'),
'#date_date_format' => $date_format,
'#date_format_string_type' => $format_type,
'#date_date_element' => 'date',
'#date_date_callbacks' => array(),
'#date_time_format' => $time_format,
......@@ -341,7 +338,7 @@ function template_preprocess_datetime_wrapper(&$variables) {
* The form element whose value has been processed.
*/
function datetime_datetime_form_process($element, &$form_state) {
$format_settings = array('format_string_type' => $element['#date_format_string_type']);
$format_settings = array();
// The value callback has populated the #value array.
$date = !empty($element['#value']['object']) ? $element['#value']['object'] : NULL;
......@@ -468,8 +465,7 @@ function form_type_datetime_value($element, $input = FALSE) {
try {
$date_time_format = trim($date_format . ' ' . $time_format);
$date_time_input = trim($date_input . ' ' . $time_input);
$date_time_settings = array('format_string_type' => $element['#date_format_string_type']);
$date = DrupalDateTime::createFromFormat($date_time_format, $date_time_input, $timezone, $date_time_settings);
$date = DrupalDateTime::createFromFormat($date_time_format, $date_time_input, $timezone);
}
catch (\Exception $e) {
$date = NULL;
......@@ -484,8 +480,8 @@ function form_type_datetime_value($element, $input = FALSE) {
$date = $element['#default_value'];
if ($date instanceOf DrupalDateTime && !$date->hasErrors()) {
$input = array(
'date' => $date->format($element['#date_date_format'], array('format_string_type' => $element['#date_format_string_type'])),
'time' => $date->format($element['#date_time_format'], array('format_string_type' => $element['#date_format_string_type'])),
'date' => $date->format($element['#date_date_format']),
'time' => $date->format($element['#date_time_format']),
'object' => $date,
);
}
......@@ -564,16 +560,15 @@ function datetime_datetime_validate($element, &$form_state) {
* if this is not a HTML5 element.
*/
function datetime_html5_format($part, $element) {
$format_type = datetime_default_format_type();
switch ($part) {
case 'date':
switch ($element['#date_date_element']) {
case 'date':
return entity_load('date_format', 'html_date')->getPattern($format_type);
return entity_load('date_format', 'html_date')->getPattern();
case 'datetime':
case 'datetime-local':
return entity_load('date_format', 'html_datetime')->getPattern($format_type);
return entity_load('date_format', 'html_datetime')->getPattern();
default:
return $element['#date_date_format'];
......@@ -583,7 +578,7 @@ function datetime_html5_format($part, $element) {
case 'time':
switch ($element['#date_time_element']) {
case 'time':
return entity_load('date_format', 'html_time')->getPattern($format_type);
return entity_load('date_format', 'html_time')->getPattern();
default:
return $element['#date_time_format'];
......@@ -604,12 +599,11 @@ function datetime_html5_format($part, $element) {
*
*/
function datetime_format_example($format) {
$format_type = datetime_default_format_type();
$date = &drupal_static(__FUNCTION__);
if (empty($date)) {
$date = new DrupalDateTime();
}
return $date->format($format, array('format_string_type' => $format_type));
return $date->format($format);
}
/**
......@@ -987,12 +981,10 @@ function datetime_range_years($string, $date = NULL) {
* Implements hook_form_BASE_FORM_ID_alter() for node forms.
*/
function datetime_form_node_form_alter(&$form, &$form_state, $form_id) {
$format_type = datetime_default_format_type();
// Alter the 'Authored on' date to use datetime.
$form['created']['#type'] = 'datetime';
$date_format = entity_load('date_format', 'html_date')->getPattern($format_type);
$time_format = entity_load('date_format', 'html_time')->getPattern($format_type);
$date_format = entity_load('date_format', 'html_date')->getPattern();
$time_format = entity_load('date_format', 'html_time')->getPattern();
$form['created']['#description'] = t('Format: %format. Leave blank to use the time of form submission.', array('%format' => datetime_format_example($date_format . ' ' . $time_format)));
unset($form['created']['#maxlength']);
}
......
......@@ -45,8 +45,6 @@ public function __construct($plugin_id, $plugin_definition, FieldDefinitionInter
* {@inheritdoc}
*/
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) {
$format_type = datetime_default_format_type();
// We are nesting some sub-elements inside the parent, so we need a wrapper.
// We also need to add another #title attribute at the top level for ease in
// identifying this item in error messages. We do not want to display this
......@@ -62,7 +60,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
case DateTimeItem::DATETIME_TYPE_DATE:
$date_type = 'date';
$time_type = 'none';
$date_format = $this->dateStorage->load('html_date')->getPattern($format_type);
$date_format = $this->dateStorage->load('html_date')->getPattern();
$time_format = '';
$element_format = $date_format;
$storage_format = DATETIME_DATE_STORAGE_FORMAT;
......@@ -71,8 +69,8 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
default:
$date_type = 'date';
$time_type = 'time';
$date_format = $this->dateStorage->load('html_date')->getPattern($format_type);
$time_format = $this->dateStorage->load('html_time')->getPattern($format_type);
$date_format = $this->dateStorage->load('html_date')->getPattern();
$time_format = $this->dateStorage->load('html_time')->getPattern();
$element_format = $date_format . ' ' . $time_format;
$storage_format = DATETIME_DATETIME_STORAGE_FORMAT;
break;
......
......@@ -104,9 +104,8 @@ function testDateField() {
// Submit a valid date and ensure it is accepted.
$value = '2012-12-31 00:00:00';
$date = new DrupalDateTime($value);
$format_type = $date->canUseIntl() ? DrupalDateTime::INTL : DrupalDateTime::PHP;
$date_format = entity_load('date_format', 'html_date')->getPattern($format_type);
$time_format = entity_load('date_format', 'html_time')->getPattern($format_type);
$date_format = entity_load('date_format', 'html_date')->getPattern();
$time_format = entity_load('date_format', 'html_time')->getPattern();
$edit = array(
'user_id' => 1,
......@@ -174,9 +173,8 @@ function testDatetimeField() {
// Submit a valid date and ensure it is accepted.
$value = '2012-12-31 00:00:00';
$date = new DrupalDateTime($value);
$format_type = $date->canUseIntl() ? DrupalDateTime::INTL : DrupalDateTime::PHP;
$date_format = entity_load('date_format', 'html_date')->getPattern($format_type);
$time_format = entity_load('date_format', 'html_time')->getPattern($format_type);
$date_format = entity_load('date_format', 'html_date')->getPattern();
$time_format = entity_load('date_format', 'html_time')->getPattern();
$edit = array(
'user_id' => 1,
......
......@@ -117,7 +117,7 @@ function testConfigTranslation() {
// Get translation and check we've only got the site name.
$translation = $wrapper->getTranslation($langcode);
$format = $translation->get('pattern')->get('php')->getValue();
$format = $translation->get('pattern')->getValue();
$this->assertEqual($format, 'D', 'Got the right date format pattern after translation.');
// Formatting the date 8 / 27 / 1985 @ 13:37 EST with pattern D should
......
......@@ -24,7 +24,7 @@ class EntityDateFormat extends EntityConfigBase {
*/
protected function updateEntityProperty(EntityInterface $entity, array $parents, $value) {
if ($parents[0] == 'pattern') {
$entity->setPattern($value, $parents[1]);
$entity->setPattern($value);
}
else {
parent::updateEntityProperty($entity, $parents, $value);
......
......@@ -44,13 +44,13 @@ public function setUp() {
*/
public function testDateFormats() {
$short_date_format = entity_load('date_format', 'short');
$this->assertEqual('\S\H\O\R\T m/d/Y - H:i', $short_date_format->getPattern(DrupalDateTime::PHP));
$this->assertEqual('\S\H\O\R\T m/d/Y - H:i', $short_date_format->getPattern());
$medium_date_format = entity_load('date_format', 'medium');
$this->assertEqual('\M\E\D\I\U\M D, m/d/Y - H:i', $medium_date_format->getPattern(DrupalDateTime::PHP));
$this->assertEqual('\M\E\D\I\U\M D, m/d/Y - H:i', $medium_date_format->getPattern());
$long_date_format = entity_load('date_format', 'long');
$this->assertEqual('\L\O\N\G l, F j, Y - H:i', $long_date_format->getPattern(DrupalDateTime::PHP));
$this->assertEqual('\L\O\N\G l, F j, Y - H:i', $long_date_format->getPattern());
// Test that we can re-import using the EntityDateFormat destination.
Database::getConnection('default', 'migrate')
......@@ -64,7 +64,7 @@ public function testDateFormats() {
$executable->import();
$short_date_format = entity_load('date_format', 'short');
$this->assertEqual('\S\H\O\R\T d/m/Y - H:i', $short_date_format->getPattern(DrupalDateTime::PHP));
$this->assertEqual('\S\H\O\R\T d/m/Y - H:i', $short_date_format->getPattern());
}
......
......@@ -3,6 +3,4 @@ label: 'Fallback date format'
status: true
langcode: en
locked: true
pattern:
php: 'D, m/d/Y - H:i'
intl: 'ccc, MM/dd/yyyy - kk:mm'
pattern: 'D, m/d/Y - H:i'
......@@ -3,6 +3,4 @@ label: 'HTML Date'
status: true
langcode: en
locked: true
pattern:
php: Y-m-d
intl: yyyy-MM-dd
pattern: Y-m-d
......@@ -3,6 +3,4 @@ label: 'HTML Datetime'
status: true
langcode: en
locked: true
pattern:
php: 'Y-m-d\TH:i:sO'
intl: 'yyyy-MM-dd''T''kk:mm:ssZZ'
pattern: 'Y-m-d\TH:i:sO'
......@@ -3,6 +3,4 @@ label: 'HTML Month'
status: true
langcode: en
locked: true
pattern:
php: Y-m
intl: Y-MM
pattern: Y-m
......@@ -3,6 +3,4 @@ label: 'HTML Time'
status: true
langcode: en
locked: true
pattern:
php: 'H:i:s'
intl: 'H:mm:ss'
pattern: 'H:i:s'
......@@ -3,6 +3,4 @@ label: 'HTML Week'
status: true
langcode: en
locked: true
pattern:
php: Y-\WW
intl: 'Y-''W''WW'
pattern: Y-\WW
......@@ -3,6 +3,4 @@ label: 'HTML Year'
status: true
langcode: en
locked: true
pattern:
php: Y
intl: Y
pattern: Y
......@@ -3,6 +3,4 @@ label: 'HTML Yearless date'
status: true
langcode: en
locked: true
pattern:
php: m-d
intl: MM-d
pattern: m-d
......@@ -3,6 +3,4 @@ label: 'Default long date'
status: true
langcode: en
locked: false
pattern:
php: 'l, F j, Y - H:i'
intl: 'EEEE, LLLL d, yyyy - kk:mm'
pattern: 'l, F j, Y - H:i'
......@@ -3,6 +3,4 @@ label: 'Default medium date'
status: true
langcode: en
locked: false
pattern:
php: 'D, m/d/Y - H:i'
intl: 'ccc, MM/dd/yyyy - kk:mm'
pattern: 'D, m/d/Y - H:i'
......@@ -3,6 +3,4 @@ label: 'Default short date'
status: true
langcode: en
locked: false
pattern:
php: 'm/d/Y - H:i'
intl: 'MM/dd/yyyy - kk:mm'
pattern: 'm/d/Y - H:i'
......@@ -134,15 +134,8 @@ system.date_format.*:
type: boolean
label: 'Locked'
pattern:
type: mapping
label: 'Format string'
mapping:
php:
type: date_format
label: 'PHP date format'
intl:
type: string
label: 'Intl date format'
type: date_format
label: 'PHP date format'
langcode:
type: string
label: 'Default language'
......
......@@ -18,26 +18,21 @@ interface DateFormatInterface extends ConfigEntityInterface {
/**
* Gets the date pattern string for this format.
*
* @param string $type
* The date pattern type to set.
*
* @return string
* The pattern string as expected by date().
*/
public function getPattern($type = DrupalDateTime::PHP);
public function getPattern();
/**
* Sets the date pattern for this format.
*
* @param string $pattern
* The date pattern to use for this format.
* @param string $type
* The date pattern type to set.
*
* @return self
* Returns the date format.
*/
public function setPattern($pattern, $type = DrupalDateTime::PHP);
public function setPattern($pattern);
/**
* Determines if this date format is locked.
......
......@@ -85,15 +85,15 @@ public function toArray() {
/**
* {@inheritdoc}
*/
public function getPattern($type = DrupalDateTime::PHP) {
return isset($this->pattern[$type]) ? $this->pattern[$type] : '';
public function getPattern() {
return $this->pattern;
}
/**
* {@inheritdoc}
*/
public function setPattern($pattern, $type = DrupalDateTime::PHP) {
$this->pattern[$type] = $pattern;
public function setPattern($pattern) {
$this->pattern = $pattern;
return $this;
}
......
......@@ -20,7 +20,7 @@ public function form(array $form, array &$form_state) {
$now = t('Displayed as %date', array('%date' => $this->dateService->format(REQUEST_TIME, $this->entity->id())));
$form['date_format_pattern']['#field_suffix'] = ' <small id="edit-date-format-suffix">' . $now . '</small>';
$form['date_format_pattern']['#default_value'] = $this->entity->getPattern($this->patternType);
$form['date_format_pattern']['#default_value'] = $this->entity->getPattern();
return $form;
}
......
......@@ -21,13 +21,6 @@
*/
abstract class DateFormatFormBase extends EntityForm {
/**
* The date pattern type.
*
* @var string
*/
protected $patternType;
/**
* The date service.
*
......@@ -52,7 +45,6 @@ abstract class DateFormatFormBase extends EntityForm {
*/
public function __construct(Date $date_service, ConfigEntityStorageInterface $date_format_storage) {
$date = new DrupalDateTime();
$this->patternType = $date->canUseIntl() ? DrupalDateTime::INTL : DrupalDateTime::PHP;
$this->dateService = $date_service;
$this->dateFormatStorage = $date_format_storage;
......@@ -136,17 +128,11 @@ public function form(array $form, array &$form_state) {
),
);
if (class_exists('intlDateFormatter')) {
$description = t('A user-defined date format. See the <a href="@url">PHP manual</a> for available options.', array('@url' => 'http://userguide.icu-project.org/formatparse/datetime'));
}
else {
$description = t('A user-defined date format. See the <a href="@url">PHP manual</a> for available options.', array('@url' => 'http://php.net/manual/function.date.php'));
}
$form['date_format_pattern'] = array(
'#type' => 'textfield',
'#title' => t('Format string'),
'#maxlength' => 100,
'#description' => $description,
'#description' => $this->t('A user-defined date format. See the <a href="@url">PHP manual</a> for available options.', array('@url' => 'http://php.net/manual/function.date.php')),
'#default_value' => '',
'#field_suffix' => ' <small id="edit-date-format-suffix"></small>',
'#ajax' => array(
......@@ -190,7 +176,7 @@ public function validate(array $form, array &$form_state) {
*/
public function submit(array $form, array &$form_state) {
$form_state['redirect_route']['route_name'] = 'system.date_format_list';
$form_state['values']['pattern'][$this->patternType] = trim($form_state['values']['date_format_pattern']);
$form_state['values']['pattern'] = trim($form_state['values']['date_format_pattern']);
parent::submit($form, $form_state);
$this->entity->save();
......
<?php
/**
* @file
* Contains \Drupal\system\Tests\Datetime\DateTimePlusIntlTest.
*/
namespace Drupal\system\Tests\Datetime;
use Drupal\Component\Datetime\DateTimePlus;
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\simpletest\DrupalUnitTestBase;
/**
* Tests use of PHP's internationalization extension to format dates.
*/
class DateTimePlusIntlTest extends DrupalUnitTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('system');
public static function getInfo() {
return array(
'name' => 'DateTimePlusIntl',
'description' => 'Test DateTimePlus PECL Intl functionality.',
'group' => 'Datetime',