diff --git a/scheduler.module b/scheduler.module index 5339efd..eaa01cf 100644 --- a/scheduler.module +++ b/scheduler.module @@ -336,7 +336,9 @@ function scheduler_form_alter(&$form, $form_state) { ); } - $description_format = t('Format: %time.', array('%time' => format_date(time(), 'custom', $date_format))); + $description_format = t('Format: %time. Relative dates are available, Examples: now, now +1 day, 12AM today, Monday next week. More examples of relative date formats in the PHP documentation.', + array('%time' => format_date(time(), 'custom', $date_format), '@relative_format' => 'http://www.php.net/manual/en/datetime.formats.relative.php') + ); if ($publishing_enabled) { $description_blank = ''; if (!$publishing_required) { @@ -489,7 +491,11 @@ function _scheduler_strtotime($str) { if (_scheduler_use_date_popup()) { $date_format = SCHEDULER_DATE_FORMAT; } - $time = _scheduler_strptime(trim($str), $date_format); + if (($time = strtotime(trim($str))) !== false) { + return $time; + } else { + $time = _scheduler_strptime(trim($str), $date_format); + } } else { // $str is empty @@ -627,7 +633,7 @@ function scheduler_node_validate($node, $form) { if (!empty($node->publish_on) && !is_numeric($node->publish_on)) { $publishtime = _scheduler_strtotime($node->publish_on); if ($publishtime === FALSE) { - form_set_error('publish_on', t("The 'publish on' value does not match the expected format of %time", array('%time' => format_date(REQUEST_TIME, 'custom', $date_format)))); + form_set_error('publish_on', t("The 'publish on' value does not match the expected format of %time or any relative dates format", array('%time' => format_date(REQUEST_TIME, 'custom', $date_format)))); } elseif ($publishtime && $publishtime < REQUEST_TIME) { form_set_error('publish_on', t("The 'publish on' date must be in the future")); @@ -637,7 +643,7 @@ function scheduler_node_validate($node, $form) { if (!empty($node->unpublish_on) && !is_numeric($node->unpublish_on)) { $unpublishtime = _scheduler_strtotime($node->unpublish_on); if ($unpublishtime === FALSE) { - form_set_error('unpublish_on', t("The 'unpublish on' value does not match the expected format of %time", array('%time' => format_date(REQUEST_TIME, 'custom', $date_format)))); + form_set_error('unpublish_on', t("The 'unpublish on' value does not match the expected format of %time or any relative dates format", array('%time' => format_date(REQUEST_TIME, 'custom', $date_format)))); } elseif ($unpublishtime && $unpublishtime < REQUEST_TIME) { form_set_error('unpublish_on', t("The 'unpublish on' date must be in the future"));