diff -upr /tmp/scheduler/README.txt scheduler/README.txt
--- /tmp/scheduler/README.txt	2008-02-12 01:24:23.000000000 +0100
+++ scheduler/README.txt	2008-07-19 00:11:35.000000000 +0200
@@ -2,13 +2,11 @@
 
 README
 --------------------------------------------------------------------------
-This module allows nodes to be published and unpublished on specified dates.
-If JSCalendar is enabled (part of the JSTools module 
-<http://drupal.org/node/57285>), a popup Javascript
+This module allows nodes to be published and unpublished on specified dates. It requires Date module version 2 (http://drupal.org/project/date).
+If Date Popup module is enabled , a popup Javascript
 calendar is used to select the date and time for (un)publishing of nodes, 
 otherwise it defaults to text input.
 
-
 This module has been completely rewritten for Drupal 4.7 by:
 
 Ted Serbinski <hello [at] tedserbinski.com>
@@ -64,4 +62,5 @@ up another cron job for the scheduler to
 is at /scheduler/cron; a sample crontab entry to run scheduler every minute
 would look like:
 
-* * * * * /usr/bin/wget -O - -q "http://example.com/scheduler/cron"
\ No newline at end of file
+* * * * * /usr/bin/wget -O - -q "http://example.com/scheduler/cron"
+
diff -upr /tmp/scheduler/scheduler.info scheduler/scheduler.info
--- /tmp/scheduler/scheduler.info	2008-06-29 19:20:14.000000000 +0200
+++ scheduler/scheduler.info	2008-07-19 00:14:18.000000000 +0200
@@ -1,6 +1,8 @@
 name = Scheduler
 description = This module allows nodes to be published and unpublished on specified dates.
 core = 6.x
+dependencies[] = date_api
+dependencies[] = date_timezone
 
 ; Information added by drupal.org packaging script on 2008-06-29
 version = "6.x-1.2"
diff -upr /tmp/scheduler/scheduler.install scheduler/scheduler.install
--- /tmp/scheduler/scheduler.install	2008-06-22 14:28:15.000000000 +0200
+++ scheduler/scheduler.install	2008-07-19 00:18:11.000000000 +0200
@@ -81,3 +81,9 @@ function scheduler_update_6100() {
   $ret[] = update_sql("ALTER TABLE {scheduler} DROP COLUMN timezone");
   return $ret; 
 }
+
+// Ensure scheduler runs after Date API.
+function scheduler_update_6102() {
+  $ret = array();
+  $ret[] = update_sql("UPDATE {system} SET weight = 1 WHERE name = 'scheduler'");
+  return $ret;
+}
diff -upr /tmp/scheduler/scheduler.module scheduler/scheduler.module
--- /tmp/scheduler/scheduler.module	2008-06-11 20:44:36.000000000 +0200
+++ scheduler/scheduler.module	2008-07-19 00:07:55.000000000 +0200
@@ -65,7 +65,7 @@ function scheduler_admin() {
  * Implementation of hook_form_alter().
  */
 function scheduler_form_alter(&$form, $form_state, $form_id) {
-  //allow scheduling on a per-node-type basis
+  // Allow scheduling on a per-node-type basis.
 
   if ('node_type_form' == $form_id) {
     $form['workflow']['scheduler'] = array(
@@ -82,31 +82,22 @@ function scheduler_form_alter(&$form, $f
     );
   }
 
-  // is this a node form?
+  // Is this a node form?
   else if (isset($form['type']['#value']) && $form['type']['#value'] .'_node_form' == $form_id) {
     if (user_access('schedule (un)publishing of nodes')) {
-      // if scheduling has been enabled for this node type
+      // If scheduling has been enabled for this node type.
       if (variable_get('scheduler_'. $form['type']['#value'], 0) == 1) {
 
-        // We add the additional validation function this way to preserve any existing validation function
-        $form['#validate']['_scheduler_form_validate' ] = array();
-      
-        //use JScalendar picker for dates if the module exists and is enabled
-        $jscalendar = FALSE;
-        if (module_exists('jscalendar')) {
-          $jscalendar = TRUE;
-        }
-
         $node = $form['#node'];
 
         $date_format = variable_get('scheduler_date_format', SCHEDULER_DATE_FORMAT);
         
-        //only load the values if we are viewing an existing node
+        // 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));
         }
 	      else {
-          // init standard values
+          // Init standard values.
           $defaults = new StdClass;
           $defaults->publish_on = $defaults->unpublish_on = NULL;
           if (isset($node->publish_on) && $node->publish_on) {
@@ -126,150 +117,29 @@ function scheduler_form_alter(&$form, $f
         );
 
         $form['scheduler_settings']['publish_on'] = array(
-          '#type' => 'textfield',
+          '#type' => 'date_text',
           '#title' => t('Publish on'),
-          '#maxlength' => 25,
+          '#date_format' => $date_format,
           '#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',
           '#title' => t('Unpublish on'),
-          '#maxlength' => 25,
+          '#date_format' => $date_format,
           '#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()
         );
-      }
-    }
-  }
-}
-
-/**
- * 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_form_validate()
- * Validate the input of the publish and unpublish date fields
- */
-function _scheduler_form_validate($form_id, $form) {
-
-  $publishtime = NULL;
-  $unpublishtime = NULL;
-
-  if (isset($form['publish_on'])) {
-    $publishtime=_scheduler_strtotime($form['publish_on']);
-    if ($publishtime === FALSE) {
-      form_set_error('publish_on', t('The entered publication date is invalid.'));
-    }
-  }
 
-  if (isset($form['unpublish_on'])) {
-    $unpublishtime = _scheduler_strtotime($form['unpublish_on']);
-    if ($unpublishtime === FALSE) {
-      form_set_error('unpublish_on', t('The entered expiration date is invalid.'));
+        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';
+        }
+      }
     }
   }
-
-  if (is_integer($publishtime) && is_integer($unpublishtime) && $unpublishtime < $publishtime) {
-    form_set_error('unpublish_on', t("The expiration date is before publication date."));
-  }
 }
 
 /**
@@ -303,23 +173,23 @@ function scheduler_nodeapi(&$node, $op, 
         }
         break;
       case 'presave':
-        // adjust the entered times for timezone consideration.
+        // Adjust the entered times for timezone consideration.
         // Note, we must check to see if the value is numeric,
-        // if it is, assume we have already done the strtotime
-        // conversation. This prevents us running strtotime on
+        // if it is, assume we have already done the date_convert
+        // conversion. This prevents us running date_convert on
         // a value we have already converted. This is needed
         // because DRUPAL6 removed 'submit' and added 'presave'
         // and all this happens at different times.
 
         if (isset($node->publish_on) && !is_numeric($node->publish_on)) {
-          $node->publish_on = _scheduler_strtotime($node->publish_on);
+          $node->publish_on = date_convert($node->publish_on, DATE_DATETIME, DATE_UNIX);
         }
 
         if (isset($node->unpublish_on) && !is_numeric($node->unpublish_on)) {
-          $node->unpublish_on = _scheduler_strtotime($node->unpublish_on);
+          $node->unpublish_on = date_convert($node->unpublish_on, DATE_DATETIME, DATE_UNIX);
         }
 
-        // right before we save the node, we need to check if a "publish on" value has been set
+        // Right before we save the node, we need to check if a "publish on" value has been set
         // if it has been set, we want to make sure the node is unpublished
         // since it will be published at a later date (but only if the value is in the future.
         if (isset($node->publish_on) && $node->publish_on != '' && is_numeric($node->publish_on) && $node->publish_on > time()) {
@@ -327,7 +197,7 @@ function scheduler_nodeapi(&$node, $op, 
         }
         break;
       case 'insert':
-        // only insert into database if we need to (un)publish this node at some date
+        // Only insert into database if we need to (un)publish this node at some date.
         if (isset($node->nid) && $node->nid && (isset($node->publish_on) && $node->publish_on != NULL) || (isset($node->unpublish_on) && $node->unpublish_on != NULL)) {
           db_query('INSERT INTO {scheduler} (nid, publish_on, unpublish_on) VALUES (%d, %d, %d)', $node->nid, $node->publish_on, $node->unpublish_on);
         }
@@ -336,10 +206,10 @@ function scheduler_nodeapi(&$node, $op, 
         if (isset($node->nid) && $node->nid) {
           $exists = db_result(db_query('SELECT nid FROM {scheduler} WHERE nid = %d', $node->nid));
   
-          // if this node has already been scheduled, update its record
+          // If this node has already been scheduled, update its record.
           if ($exists) {
-            // only update database if we need to (un)publish this node at some date
-            // otherwise the user probably cleared out the (un)publish dates so we should remove the record
+            // Only update database if we need to (un)publish this node at some date
+            // otherwise the user probably cleared out the (un)publish dates so we should remove the record.
             if ((isset($node->publish_on) && $node->publish_on != NULL) || (isset($node->unpublish_on) && $node->unpublish_on != NULL)) {
               db_query('UPDATE {scheduler} SET publish_on = %d, unpublish_on = %d WHERE nid = %d', $node->publish_on, $node->unpublish_on, $node->nid);
             }
@@ -347,7 +217,7 @@ function scheduler_nodeapi(&$node, $op, 
               db_query('DELETE FROM {scheduler} WHERE nid = %d', $node->nid);
             }
           }
-          // node doesn't exist, create a record only if the (un)publish fields are blank
+          // Node doesn't exist, create a record only if the (un)publish fields are blank.
           else if ((isset($node->publish_on) && $node->publish_on != NULL) || (isset($node->unpublish_on) && $node->unpublish_on != NULL)) {
             db_query('INSERT INTO {scheduler} (nid, publish_on, unpublish_on) VALUES (%d, %d, %d)', $node->nid, $node->publish_on, $node->unpublish_on);
           }
@@ -368,7 +238,7 @@ function scheduler_nodeapi(&$node, $op, 
 function scheduler_cron() {
   $clear_cache = FALSE;
 
-  // if the time now is greater than the time to publish a node, publish it
+  // If the time now is greater than the time to publish a node, publish it.
   $nodes = db_query('SELECT * FROM {scheduler} s LEFT JOIN {node} n ON s.nid = n.nid WHERE n.status = 0 AND s.publish_on > 0 AND s.publish_on < %d ', time());
 
   while ($node = db_fetch_object($nodes)) {
@@ -384,26 +254,26 @@ function scheduler_cron() {
     $context['node'] = $n;
     actions_do($actions, $n, $context, NULL, NULL);
 
-    // if this node is not to be unpublished, then we can delete the record
+    // If this node is not to be unpublished, then we can delete the record.
     if (isset($n->unpublish_on) && $n->unpublish_on == 0) {
       db_query('DELETE FROM {scheduler} WHERE nid = %d', $n->nid);
     }
-    // we need to unpublish this node at some time so clear the publish on since it's been published
+    // We need to unpublish this node at some time so clear the publish on since it's been published.
     else {
       db_query('UPDATE {scheduler} SET publish_on = 0 WHERE nid = %d', $n->nid);
     }
 
-    // invoke scheduler API
+    // Invoke scheduler API.
     _scheduler_scheduler_api($n, 'publish');
 
     $clear_cache = TRUE;
   }
 
-  // if the time is greater than the time to unpublish a node, unpublish it
+  // If the time is greater than the time to unpublish a node, unpublish it.
   $nodes = db_query('SELECT * FROM {scheduler} s LEFT JOIN {node} n ON s.nid = n.nid WHERE n.status = 1 AND s.unpublish_on > 0 AND s.unpublish_on < %d', time());
 
   while ($node = db_fetch_object($nodes)) {
-    // if this node is to be unpublished, we can update the node and remove the record since it can't be republished
+    // If this node is to be unpublished, we can update the node and remove the record since it can't be republished.
     $n = node_load($node->nid);
     $n->changed = $node->unpublish_on;
 
@@ -414,20 +284,20 @@ function scheduler_cron() {
     actions_do($actions, $n, $context, NULL, NULL);
     db_query('DELETE FROM {scheduler} WHERE nid = %d', $n->nid);
 
-    // invoke scheduler API
+    // Invoke scheduler API.
     _scheduler_scheduler_api($n, 'unpublish');
 
     $clear_cache = TRUE;
   }
 
   if ($clear_cache) {
-    // clear the cache so an anonymous poster can see the node being published or unpublished
+    // Clear the cache so an anonymous poster can see the node being published or unpublished.
     cache_clear_all();
   }
 }
 
 /**
- * Implementation of hook_theme()
+ * Implementation of hook_theme().
  */
 function scheduler_theme() {
   return array(
@@ -450,7 +320,7 @@ function _scheduler_run_cron() {
 }
 
 /**
- * Scheduler API to perform actions when nodes are (un)published
+ * Scheduler API to perform actions when nodes are (un)published.
  *
  * @param $node
  *  The node object
@@ -491,7 +361,7 @@ function theme_scheduler_timecheck($now)
 }
 
 /**
- * Implementation of "contrib module views" hook_views_tables()
+ * Implementation of "contrib module views" hook_views_tables().
  */
 function scheduler_views_tables() {
   $tables['scheduler'] = array(
