Skip to content
This repository was archived by the owner on Aug 14, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions sites/all/modules/contrib/date/date.field.inc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function date_field_formatter_info() {
'settings' => array(
'interval' => 2,
'interval_display' => 'time ago',
'use_end_date' => false,
),
),
'date_plain' => array(
Expand Down Expand Up @@ -207,7 +208,7 @@ function date_field_formatter_view($entity_type, $entity, $field, $instance, $la
$variables['item'] = $item;
$variables['dates'] = date_formatter_process($formatter, $entity_type, $entity, $field, $instance, $langcode, $item, $display);
$variables['attributes'] = !empty($rdf_mapping) ? rdf_rdfa_attributes($rdf_mapping, $item['value']) : array();
$variables['show_remaining_days'] = $display['settings']['show_remaining_days'];
$variables['show_remaining_days'] = isset($display['settings']['show_remaining_days']) ? $display['settings']['show_remaining_days'] : FALSE;
$output = theme('date_display_combination', $variables);
if (!empty($output)) {
$element[$delta] = array('#markup' => $output);
Expand Down Expand Up @@ -322,7 +323,7 @@ function date_field_widget_info() {
}

// The date text widget should use an increment of 1.
$info['date_text']['increment'] = 1;
$info['date_text']['settings']['increment'] = 1;

return $info;
}
Expand Down Expand Up @@ -462,6 +463,14 @@ function date_field_instance_settings_form($field, $instance) {
return _date_field_instance_settings_form($field, $instance);
}

/**
* Form validation handler for _date_field_instance_settings_form().
*/
function date_field_instance_settings_form_validate(&$form, &$form_state) {
module_load_include('inc', 'date', 'date_admin');
return _date_field_instance_settings_form_validate($form, $form_state);
}

/**
* Implements hook_field_widget_settings_form().
*/
Expand All @@ -470,6 +479,14 @@ function date_field_widget_settings_form($field, $instance) {
return _date_field_widget_settings_form($field, $instance);
}

/**
* Form validation handler for _date_field_widget_settings_form().
*/
function date_field_widget_settings_form_validate(&$form, &$form_state) {
module_load_include('inc', 'date', 'date_admin');
return _date_field_widget_settings_form_validate($form, $form_state);
}

/**
* Implements hook_field_settings_form().
*/
Expand All @@ -478,6 +495,14 @@ function date_field_settings_form($field, $instance, $has_data) {
return _date_field_settings_form($field, $instance, $has_data);
}

/**
* Form validation handler for _date_field_settings_form().
*/
function date_field_settings_validate(&$form, &$form_state) {
module_load_include('inc', 'date', 'date_admin');
return _date_field_settings_validate($form, $form_state);
}

/**
* Implements hook_content_migrate_field_alter().
*
Expand Down
7 changes: 4 additions & 3 deletions sites/all/modules/contrib/date/date.info
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ files[] = tests/date_validation.test
files[] = tests/date_timezone.test
files[] = tests/date_views_pager.test
files[] = tests/date_views_popup.test
files[] = tests/date_form.test

; Information added by Drupal.org packaging script on 2015-09-08
version = "7.x-2.9"
; Information added by Drupal.org packaging script on 2017-04-07
version = "7.x-2.10"
core = "7.x"
project = "date"
datestamp = "1441727353"
datestamp = "1491562090"

8 changes: 8 additions & 0 deletions sites/all/modules/contrib/date/date.install
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,11 @@ function date_update_7004() {
field_cache_clear();
drupal_set_message(t('Date text widgets have been updated to use an increment of 1.'));
}

/**
* Revisited: Date text widgets should always use an increment of 1.
*/
function date_update_7005() {
// @see https://www.drupal.org/node/1355256
date_update_7004();
}
5 changes: 4 additions & 1 deletion sites/all/modules/contrib/date/date.migrate.inc
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<?php

/**
* @file
* Support for migration into Date fields.
*/

if (!class_exists('MigrateFieldHandler')) {
return;
}

/**
* Implements hook_migrate_api().
*/
Expand Down
7 changes: 6 additions & 1 deletion sites/all/modules/contrib/date/date.module
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,12 @@ function date_formatter_format($formatter, $settings, $granularity = array(), $l
return 'date_plain';

default:
$format = date_format_type_format($format_type, $langcode);
if ($format_type == 'custom') {
$format = $settings['custom_date_format'];
}
else {
$format = date_format_type_format($format_type, $langcode);
}
break;
}

Expand Down
10 changes: 6 additions & 4 deletions sites/all/modules/contrib/date/date.theme
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,10 @@ function theme_date_display_range($variables) {
}

// Wrap the result with the attributes.
$output = '<div class="date-display-range">' . t('!start-date to !end-date', array(
$output = '<span class="date-display-range">' . t('!start-date to !end-date', array(
'!start-date' => $start_date,
'!end-date' => $end_date,
)) . '</div>';
)) . '</span>';

// Add remaining message and return.
return $output . $show_remaining_days;
Expand All @@ -378,6 +378,8 @@ function theme_date_display_interval($variables) {
'end_date' => $dates['value2']['local']['object'],
'interval' => $options['interval'],
'interval_display' => $options['interval_display'],
'use_end_date' => !empty($options['use_end_date']) ?
$options['use_end_date'] : FALSE,
);

if ($return = theme('date_time_ago', $time_ago_vars)) {
Expand All @@ -398,9 +400,9 @@ function theme_date_combo($variables) {

// Group start/end items together in fieldset.
$fieldset = array(
'#title' => field_filter_xss(t($element['#title'])) . ' ' . ($element['#delta'] > 0 ? intval($element['#delta'] + 1) : ''),
'#title' => field_filter_xss(t($element['#title'])) . ($element['#delta'] > 0 ? ' ' . intval($element['#delta'] + 1) : ''),
'#value' => '',
'#description' => !empty($element['#fieldset_description']) ? $element['#fieldset_description'] : '',
'#description' => !empty($element['#description']) ? $element['#description'] : '',
'#attributes' => array('class' => array('date-combo')),
'#children' => $element['#children'],
);
Expand Down
31 changes: 25 additions & 6 deletions sites/all/modules/contrib/date/date_admin.inc
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,24 @@ function date_default_formatter_settings_form($field, $instance, $view_mode, $fo
$formatter = $display['type'];
$form = array();

$date_formats = date_format_type_options();
$form['format_type'] = array(
'#title' => t('Choose how users view dates and times:'),
'#type' => 'select',
'#options' => date_format_type_options(),
'#options' => $date_formats + array('custom' => t('Custom')),
'#default_value' => $settings['format_type'],
'#description' => t('To add or edit options, visit <a href="@date-time-page">Date and time settings</a>.', array('@date-time-page' => url('admin/config/regional/date-time'))),
'#weight' => 0,
);

$form['custom_date_format'] = array(
'#type' => 'textfield',
'#title' => t('Custom date format'),
'#description' => t('If "Custom", see the <a href="@url" target="_blank">PHP manual</a> for date formats. Otherwise, enter the number of different time units to display, which defaults to 2.', array('@url' => 'http://php.net/manual/function.date.php')),
'#default_value' => isset($settings['custom_date_format']) ? $settings['custom_date_format'] : '',
'#dependency' => array('edit-options-settings-format-type' => array('custom')),
);

$form['fromto'] = array(
'#title' => t('Display:'),
'#type' => 'select',
Expand Down Expand Up @@ -116,6 +125,14 @@ function date_interval_formatter_settings_form($field, $instance, $view_mode, $f
'#default_value' => $settings['interval_display'],
'#weight' => 0,
);
if (!empty($field['settings']['todate'])) {
$form['use_end_date'] = array(
'#title' => t('Use End date'),
'#description' => 'Use the End date, instead of the start date',
'#type' => 'checkbox',
'#default_value' => $settings['use_end_date'],
);
}
return $form;
}

Expand Down Expand Up @@ -186,7 +203,9 @@ function date_interval_formatter_settings_summary($field, $instance, $view_mode)
$display = $instance['display'][$view_mode];
$settings = $display['settings'];
$formatter = $display['type'];
$summary[] = t('Display time ago, showing @interval units.', array('@interval' => $settings['interval']));
$field = ($settings['use_end_date'] == 1) ? 'End' : 'Start';
$summary[] = t('Display time ago, showing @interval units. Using @field Date',
array('@interval' => $settings['interval'], '@field' => $field));

return $summary;
}
Expand Down Expand Up @@ -273,7 +292,7 @@ function _date_field_instance_settings_form($field, $instance) {
/**
* Form validation handler for _date_field_instance_settings_form().
*/
function date_field_instance_settings_form_validate(&$form, &$form_state) {
function _date_field_instance_settings_form_validate(&$form, &$form_state) {
$settings = $form_state['values']['instance']['settings'];

if ($settings['default_value'] == 'strtotime') {
Expand Down Expand Up @@ -459,7 +478,7 @@ function _date_field_widget_settings_form($field, $instance) {
/**
* Form validation handler for _date_field_widget_settings_form().
*/
function date_field_widget_settings_form_validate(&$form, &$form_state) {
function _date_field_widget_settings_form_validate(&$form, &$form_state) {
// The widget settings are in the wrong place in the form because of #tree on
// the top level.
$settings = $form_state['values']['instance']['widget']['settings'];
Expand Down Expand Up @@ -561,7 +580,7 @@ function _date_field_settings_form($field, $instance, $has_data) {
$form['cache_enabled'] = array(
'#type' => 'checkbox',
'#title' => t('Cache dates'),
'#description' => t('Date objects can be created and cached as date fields are loaded rather than when they are displayed to improve performance.'),
'#description' => t('Date objects can be created and cached as date fields are loaded, rather than when they are displayed, to improve performance.'),
'#default_value' => !empty($settings['cache_enabled']),
'#weight' => 10,
);
Expand Down Expand Up @@ -594,7 +613,7 @@ function _date_field_settings_form($field, $instance, $has_data) {
/**
* Form validation handler for _date_field_settings_form().
*/
function date_field_settings_validate(&$form, &$form_state) {
function _date_field_settings_validate(&$form, &$form_state) {
$field = &$form_state['values']['field'];

if ($field['settings']['tz_handling'] == 'none') {
Expand Down
6 changes: 3 additions & 3 deletions sites/all/modules/contrib/date/date_all_day/date_all_day.info
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ dependencies[] = date
package = Date/Time
core = 7.x

; Information added by Drupal.org packaging script on 2015-09-08
version = "7.x-2.9"
; Information added by Drupal.org packaging script on 2017-04-07
version = "7.x-2.10"
core = "7.x"
project = "date"
datestamp = "1441727353"
datestamp = "1491562090"

6 changes: 3 additions & 3 deletions sites/all/modules/contrib/date/date_api/date_api.info
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ stylesheets[all][] = date.css
files[] = date_api.module
files[] = date_api_sql.inc

; Information added by Drupal.org packaging script on 2015-09-08
version = "7.x-2.9"
; Information added by Drupal.org packaging script on 2017-04-07
version = "7.x-2.10"
core = "7.x"
project = "date"
datestamp = "1441727353"
datestamp = "1491562090"

26 changes: 20 additions & 6 deletions sites/all/modules/contrib/date/date_api/date_api.module
Original file line number Diff line number Diff line change
Expand Up @@ -1833,9 +1833,10 @@ function date_format_interval($date, $granularity = 2, $display_ago = TRUE) {
/**
* A date object for the current time.
*
* @param object $timezone
* (optional) Optionally force time to a specific timezone, defaults to user
* timezone, if set, otherwise site timezone. Defaults to NULL.
* @param object|string|null $timezone
* (optional) PHP DateTimeZone object, string or NULL allowed. Optionally
* force time to a specific timezone, defaults to user timezone, if set,
* otherwise site timezone. Defaults to NULL.
*
* @param bool $reset
* (optional) Static cache reset.
Expand All @@ -1844,11 +1845,16 @@ function date_format_interval($date, $granularity = 2, $display_ago = TRUE) {
* The current time as a date object.
*/
function date_now($timezone = NULL, $reset = FALSE) {
$static_var = __FUNCTION__ . $timezone;
if ($timezone instanceof DateTimeZone) {
$static_var = __FUNCTION__ . $timezone->getName();
}

if ($reset) {
drupal_static_reset(__FUNCTION__ . $timezone);
drupal_static_reset($static_var);
}

$now = &drupal_static(__FUNCTION__ . $timezone);
$now = &drupal_static($static_var);

if (!isset($now)) {
$now = new DateObject('now', $timezone);
Expand Down Expand Up @@ -1920,7 +1926,12 @@ function date_days_in_month($year, $month) {
// Pick a day in the middle of the month to avoid timezone shifts.
$datetime = date_pad($year, 4) . '-' . date_pad($month) . '-15 00:00:00';
$date = new DateObject($datetime);
return $date->format('t');
if ($date->errors) {
return FALSE;
}
else {
return $date->format('t');
}
}

/**
Expand Down Expand Up @@ -2075,6 +2086,9 @@ function date_iso_week_range($week, $year) {
date_timezone_set($min_date, date_default_timezone_object());

// Find the first day of the first ISO week in the year.
// If it's already a Monday, date_modify won't add a Monday,
// it will remain the same day. So add a Sunday first, then a Monday.
date_modify($min_date, '+1 Sunday');
date_modify($min_date, '+1 Monday');

// Jump ahead to the desired week for the beginning of the week range.
Expand Down
4 changes: 2 additions & 2 deletions sites/all/modules/contrib/date/date_api/date_api_elements.inc
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function date_default_date($element) {
$format = DATE_FORMAT_DATETIME;

// The text and popup widgets might return less than a full datetime string.
if (strlen($element['#default_value']) < 19) {
if (is_string($element['#default_value']) && strlen($element['#default_value']) < 19) {
switch (strlen($element['#default_value'])) {
case 16:
$format = 'Y-m-d H:i';
Expand Down Expand Up @@ -319,7 +319,7 @@ function date_text_element_process($element, &$form_state, $form) {

$element['#tree'] = TRUE;
$element['#theme_wrappers'] = array('date_text');
$element['date']['#value'] = $element['#value']['date'];
$element['date']['#value'] = isset($element['#value']['date']) ? $element['#value']['date'] : '';
$element['date']['#type'] = 'textfield';
$element['date']['#weight'] = !empty($element['date']['#weight']) ? $element['date']['#weight'] : $element['#weight'];
$element['date']['#attributes'] = array('class' => isset($element['#attributes']['class']) ? $element['#attributes']['class'] += array('date-date') : array('date-date'));
Expand Down
13 changes: 11 additions & 2 deletions sites/all/modules/contrib/date/date_api/theme/theme.inc
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ function theme_date_calendar_day($variables) {
function theme_date_time_ago($variables) {
$start_date = $variables['start_date'];
$end_date = $variables['end_date'];
$use_end_date = isset($variables['use_end_date']) ? $variables['use_end_date'] : false;
$interval = !empty($variables['interval']) ? $variables['interval'] : 2;
$display = isset($variables['interval_display']) ? $variables['interval_display'] : 'time ago';

Expand All @@ -202,12 +203,20 @@ function theme_date_time_ago($variables) {
return;
}

// We use the end date only when the option is checked.
if ($use_end_date){
$date = date_format($end_date, DATE_FORMAT_UNIX);
}
else {
$date = date_format($start_date, DATE_FORMAT_UNIX);
}

// Time to compare dates to.

$now = date_format(date_now(), DATE_FORMAT_UNIX);
$start = date_format($start_date, DATE_FORMAT_UNIX);

// Will be positive for a datetime in the past (ago), and negative for a datetime in the future (hence).
$time_diff = $now - $start;
$time_diff = $now - $date;

// Uses the same options used by Views format_interval.
switch ($display) {
Expand Down
6 changes: 3 additions & 3 deletions sites/all/modules/contrib/date/date_context/date_context.info
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ dependencies[] = context

files[] = date_context.module
files[] = plugins/date_context_date_condition.inc
; Information added by Drupal.org packaging script on 2015-09-08
version = "7.x-2.9"
; Information added by Drupal.org packaging script on 2017-04-07
version = "7.x-2.10"
core = "7.x"
project = "date"
datestamp = "1441727353"
datestamp = "1491562090"

Loading