Common subdirectories: scheduler/po and ./po
Only in .: scheduler
Only in .: scheduler-6.x-1.3.tar.gz
Only in .: scheduler_date_1.patch
diff -upd scheduler/scheduler.info ./scheduler.info
--- scheduler/scheduler.info	2008-11-04 18:45:31.000000000 +0100
+++ ./scheduler.info	2008-11-15 15:48:39.000000000 +0100
@@ -8,3 +8,5 @@ core = "6.x"
 project = "scheduler"
 datestamp = "1225820731"
 
+dependencies[] = date_api
+dependencies[] = date_timezone
diff -upd scheduler/scheduler.install ./scheduler.install
--- scheduler/scheduler.install	2008-11-01 20:06:17.000000000 +0100
+++ ./scheduler.install	2008-11-15 15:55:00.000000000 +0100
@@ -77,3 +77,10 @@ function scheduler_update_6100() {
   }
   return $ret; 
 }
+// Ensure scheduler runs after Date API.
+function scheduler_update_6101() {
+  $ret = array();
+  $ret[] = update_sql("UPDATE {system} SET weight = 1 WHERE name = 'scheduler'");
+  return $ret;
+}
+
diff -upd scheduler/scheduler.module ./scheduler.module
--- scheduler/scheduler.module	2008-11-02 21:35:50.000000000 +0100
+++ ./scheduler.module	2008-11-15 15:53:36.000000000 +0100
@@ -135,125 +135,31 @@ function scheduler_form_alter(&$form, $f
         );
 
         $form['scheduler_settings']['publish_on'] = array(
-          '#type' => 'textfield',
+          '#type' => 'date_text',
+          '#date_format' => $date_format,
           '#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))),
-          '#attributes' => $jscalendar ? array('class' => 'jscalendar') : array()
         );
 
         $form['scheduler_settings']['unpublish_on'] = array(
-          '#type' => 'textfield',
+          '#type' => 'date_text',
+          '#date_format' => $date_format,
           '#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))),
-          '#attributes' => $jscalendar ? array('class' => 'jscalendar') : array()
         );
+        if (module_exists('date_popup')) {
+          // Make this a popup calendar widget if Date Popup module is enabled.
+          $form['scheduler_settings']['publish_on']['#type'] = 'date_popup';
+          $form['scheduler_settings']['unpublish_on']['#type'] = 'date_popup';
+        }
       }
     }
   }
 }
 
 /**
- * Converts an english time string ('Y-m-d H:i:s') from the users timezone into an unix timestamp
- * @param string $str the time string ('Y-m-d H:i:s')
- * @return the time in unix timestamp representation (utc);
- * NULL, if $str is NULL, FALSE, empty, or contains only white spaces;
- * FALSE, if $str is malformed
- */
-function _scheduler_strtotime($str) {
-  if ($str && trim($str) != "" ) {
-    $time=_scheduler_strptime(trim($str), variable_get('scheduler_date_format', SCHEDULER_DATE_FORMAT));
-    if ($time!==FALSE) {
-      // success
-      $time -= _scheduler_get_user_timezone();
-    }
-  } else {
-    // $str is empty
-    $time = NULL;
-  }
-  return $time;
-}
-
-/**
- * Parse a time/date as UTC time
- *
- * @param string $date The string to parse
- * @param string $format The format used in $date. See date() (http://www.php.net/manual/en/function.date.php) 
- * specification for format options. Right now only dHhmiaAsyY are supported. 
- * @return the parsed time as a UTC timestamp
- * @see date()
- */
-function _scheduler_strptime($date, $format) {
-  # 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})'); 
-  $custom_pattern = str_replace($date_entities, $date_regex_replacements, $format);
-  if (!preg_match("#$custom_pattern#", $date, $value_matches)) {
-    return FALSE;
-  }
-  
-  if (!preg_match_all("/(\w)/", $format, $entity_matches)) {
-    return FALSE;
-  }
-
-  $results = array('day' => 0, 'hour' => 0, 'month' => 0, 'minute' => 0, 'meridiem' => NULL, 'second' => 0, 'year' => 0);
-  $index = 1;
-  foreach ($entity_matches[1] as $entity) {
-    $value = intval($value_matches[$index]);
-    switch ($entity) {
-      case 'd':
-        $results['day'] = $value;
-        break;
-      case 'H':
-      case 'h':
-        $results['hour'] = $value; 
-        break;
-      case 'm':
-        $results['month'] = $value; 
-        break;
-      case 'i':
-        $results['minute'] = $value; 
-        break;
-      case 'a':
-      case 'A':
-        $results['meridiem'] = $value_matches[$index]; 
-        break;
-      case 's':
-        $results['second'] = $value; 
-        break;
-      case 'y':
-      case 'Y':
-        $results['year'] = $value; 
-        break;
-    }    
-    $index++;
-  }
-  if ((strncasecmp($results['meridiem'], "pm", 2) == 0) && ($results['hour'] <= 12)) {
-    $results['hour'] += 12;
-  }
-
-  $time = gmmktime( $results['hour'], $results['minute'], $results['second'], $results['month'], $results['day'], $results['year'] );
-  return $time;
-}
-
-/**
- * Gets the users timezone if configurable timezones are enabled or otherwise the default timezone of the site
- *
- * @return the offset of the users timezone in seconds
- */
-function _scheduler_get_user_timezone() {
-  global $user;
-  $timezone = variable_get('date_default_timezone', 0);
-  if ((variable_get('configurable_timezones', 1) == 1) && (strlen($user->timezone))) {
-    $timezone = $user->timezone;
-  }
-  return $timezone;
-}
-
-/**
  * Implementation of hook_nodeapi().
  */
 function scheduler_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
@@ -292,7 +198,7 @@ function scheduler_nodeapi(&$node, $op, 
         // because DRUPAL6 removed 'submit' and added 'presave'
         // and all this happens at different times.
         if (isset($node->publish_on) && !is_numeric($node->publish_on)) {
-          $publishtime = _scheduler_strtotime($node->publish_on);
+          $publishtime = date_convert($node->publish_on, DATE_DATETIME, DATE_UNIX);
           if ($publishtime === FALSE) {
             form_set_error('publish_on', t('The entered publication date is invalid.'));
           }
@@ -302,7 +208,7 @@ function scheduler_nodeapi(&$node, $op, 
         }
         
         if (isset($node->unpublish_on) && !is_numeric($node->unpublish_on)) {
-          $unpublishtime = _scheduler_strtotime($node->unpublish_on);
+          $unpublishtime = date_convert($node->unpublish_on, DATE_DATETIME, DATE_UNIX);
           if ($unpublishtime === FALSE) {
             form_set_error('unpublish_on', t('The entered expiration date is invalid.'));
           }
