diff --git a/scheduler.module b/scheduler.module index 49a9b6a..bf8b7fe 100644 --- a/scheduler.module +++ b/scheduler.module @@ -238,7 +238,8 @@ function scheduler_admin_validate($form, &$form_state) { // If date-only is enabled then check if a valid default time was entered. // Allow leading zeros to be omitted, eg. 6:30:00 is considered valid. if ($form_state['values']['scheduler_allow_date_only']) { - if (!$default_time = strptime($form_state['values']['scheduler_default_time'], '%H:%M:%S')) { + $default_time = strptime($form_state['values']['scheduler_default_time'], '%H:%M:%S'); + if (!$default_time) { form_set_error('scheduler_default_time', t('The default time should be in the format HH:MM:SS')); } else { @@ -258,14 +259,14 @@ function scheduler_admin_submit($form, &$form_state) { // and end with a letter, but any punctuation between these will be retained. $format = $form_state['values']['scheduler_date_format']; $time_letters = 'gGhHisaA'; - $time_start = strcspn($format, $time_letters); - $time_length = strlen($format) - strcspn(strrev($format), $time_letters) - $time_start; + $time_start = strcspn($format, $time_letters); + $time_length = strlen($format) - strcspn(strrev($format), $time_letters) - $time_start; $time_only_format = substr($format, $time_start, $time_length); variable_set('scheduler_time_only_format', $time_only_format); $date_letters = 'djFmMnyY'; - $date_start = strcspn($format, $date_letters); - $date_length = strlen($format) - strcspn(strrev($format), $date_letters) - $date_start; + $date_start = strcspn($format, $date_letters); + $date_length = strlen($format) - strcspn(strrev($format), $date_letters) - $date_start; $date_only_format = substr($format, $date_start, $date_length); variable_set('scheduler_date_only_format', $date_only_format); @@ -436,16 +437,23 @@ function scheduler_form_alter(&$form, $form_state) { // Define the descriptions depending on whether the time can be skipped. $descriptions = array(); if ($date_only_allowed && ($date_only_format != $date_format)) { - $descriptions['format'] = t('Format: %date_only_format or %standard_format.', array('%date_only_format' => format_date(time(), 'custom', $date_only_format), '%standard_format' => format_date(time(), 'custom', $date_format))); + $descriptions['format'] = t('Format: %date_only_format or %standard_format.', array( + '%date_only_format' => format_date(time(), 'custom', $date_only_format), + '%standard_format' => format_date(time(), 'custom', $date_format), + )); } else { - $descriptions['format'] = t('Format: %standard_format.', array('%standard_format' => format_date(time(), 'custom', $date_format))); + $descriptions['format'] = t('Format: %standard_format.', array( + '%standard_format' => format_date(time(), 'custom', $date_format), + )); } // Show the default time so users know what they will get if they do not // enter a time. if ($date_only_allowed) { $default_time = strtotime(variable_get('scheduler_default_time', SCHEDULER_DEFAULT_TIME)); - $descriptions['default'] = t('The default time is @default_time.', array('@default_time' => format_date($default_time, 'custom', $time_only_format ? $time_only_format : SCHEDULER_TIME_ONLY_FORMAT))); + $descriptions['default'] = t('The default time is @default_time.', array( + '@default_time' => format_date($default_time, 'custom', $time_only_format ? $time_only_format : SCHEDULER_TIME_ONLY_FORMAT), + )); } if ($publishing_enabled) {