--- scheduler.module.orig 2008-11-02 20:35:50.000000000 +0000 +++ scheduler.module 2008-11-19 03:44:45.000000000 +0000 @@ -56,7 +56,7 @@ function scheduler_admin() { '#default_value' => variable_get('scheduler_date_format', SCHEDULER_DATE_FORMAT), '#size' => 20, '#maxlength' => 20, - '#description' => t('The input format for the (un)scheduling time/date. See the date() function for formatting options: http://www.php.net/manual/en/function.date.php'), + '#description' => t('The input format for the (un)scheduling time/date. See the date() function for formatting options: http://www.php.net/manual/en/function.date.php. Or enter "strtotime" to make PHP do the work for you. See: http://www.php.net/manual/en/function.strtotime.php :)'), ); return system_settings_form($form); } @@ -98,6 +98,15 @@ function scheduler_form_alter(&$form, $f $date_format = variable_get('scheduler_date_format', SCHEDULER_DATE_FORMAT); + // if they're using strtotime, grab the default date format for output... + if ($date_format == 'strtotime') { + $date_format = variable_get('date_format_long', 'D, m/d/Y - H:i'); + $sample_time = "'tomorrow', '+5 days' or 'next Tuesday'... just enter a date or time :)"; + } + else { + $sample_time = format_date(time(), 'custom', $date_format); + } + //only load the values if we are viewing an existing node if (isset($node->nid) && $node->nid > 0) { $defaults = db_fetch_object(db_query('SELECT publish_on, unpublish_on FROM {scheduler} WHERE nid = %d', $node->nid)); @@ -139,7 +148,7 @@ function scheduler_form_alter(&$form, $f '#title' => t('Publish on'), '#maxlength' => 25, '#default_value' => isset($defaults->publish_on) && $defaults->publish_on ? format_date($defaults->publish_on, 'custom', $date_format) : '', - '#description' => t('Format: %time. Leave blank to disable scheduled publishing.', array('%time' => format_date(time(), 'custom', $date_format))), + '#description' => t('Format: %time. Leave blank to disable scheduled publishing.', array('%time' => $sample_time)), '#attributes' => $jscalendar ? array('class' => 'jscalendar') : array() ); @@ -148,7 +157,7 @@ function scheduler_form_alter(&$form, $f '#title' => t('Unpublish on'), '#maxlength' => 25, '#default_value' => isset($defaults->unpublish_on) && $defaults->unpublish_on ? format_date($defaults->unpublish_on, 'custom', $date_format) : '', - '#description' => t('Format: %time. Leave blank to disable scheduled unpublishing.', array('%time' => format_date(time(), 'custom', $date_format))), + '#description' => t('Format: %time. Leave blank to disable scheduled unpublishing.', array('%time' => $sample_time)), '#attributes' => $jscalendar ? array('class' => 'jscalendar') : array() ); } @@ -187,6 +196,12 @@ function _scheduler_strtotime($str) { * @see date() */ function _scheduler_strptime($date, $format) { + // this seems needlessly complex. mebbe I'm not seeing something here? + // how 'bout we do it like this: + if ($format == 'strtotime') { + return strtotime($date); + } + # we need to build a regex pattern for the date format $date_entities = array('d', 'H', 'h', 'm', 'i', 'a', 'A', 's', 'y', 'Y'); $date_regex_replacements = array('(\d{2})', '(\d{2})', '(\d{2})', '(\d{2})', '(\d{2})', '([ap]m)', '([AP]M)', '(\d{2})', '(\d{2})', '(\d{4})');