--- timeline.module	2008-10-12 10:43:51.000000000 -0600
+++ date_patch_timeline.module	2008-11-29 21:50:15.000000000 -0700
@@ -417,35 +417,49 @@ function timeline_format_initial_date($t
 //////////////////////////////////////////////////////////////////////////////
 // EXTENDED DATE HELPERS (for pre-1970 dates)
 
-_timeline_load_extended_dates();
-
-function _timeline_load_extended_dates() {
-  if (!function_exists('adodb_date_test_date')) {
-    $adodb_file = 'adodb-time.inc.php';
-    $adodb_path = module_exists('date') ?
-      drupal_get_path('module', 'date') .'/'. $adodb_file :
-      drupal_get_path('module', 'timeline') .'/'. $adodb_file;
-    if (file_exists($adodb_path)) {
-      include_once($adodb_path);
-    }
+function timeline_use_date_api() {
+  if (module_exists('date_api') && variable_get('date_api_version', 0) >= 5.2) {
+    return TRUE;
+  }
+  else {
+    return FALSE;
   }
 }
 
 function _timeline_date($format, $timestamp = FALSE) {
-  $date = function_exists('adodb_date') ? 'adodb_date' : 'date';
-  return $date($format, $timestamp);
+  if (timeline_use_date_api()) {
+    if (preg_match(TIMELINE_ISO_DATE, $time, $matches)) {
+      $date = date_make_date($timestamp, date_default_timezone_name(), DATE_ISO);
+    }
+    else {
+      $date = date_make_date($timestamp, date_default_timezone_name(), DATE_UNIX);
+    }
+    return date_format($date, $format);
+  }
+  else {
+    return date($format, $timestamp);
+  }
+
 }
 
 function _timeline_gmdate($format, $timestamp = FALSE) {
-  $gmdate = function_exists('adodb_gmdate') ? 'adodb_gmdate' : 'gmdate';
-  return $gmdate($format, $timestamp);
+  if (timeline_use_date_api()) {
+    if (preg_match(TIMELINE_ISO_DATE, $time, $matches)) {
+      $date = date_make_date($timestamp, 'UTC', DATE_ISO);
+    }
+    else {
+      $date = date_make_date($timestamp, 'UTC', DATE_UNIX);
+    }
+    return date_format($date, $format);
+  }
+  else {
+    return gmdate($format, $timestamp);
+  }
 }
 
 function _timeline_strtotime($time) {
-  if (function_exists('adodb_gmmktime') && preg_match(TIMELINE_ISO_DATE, $time, $matches)) {
-    $args = array_map('intval', array_slice($matches, 1));
-    $args = array_merge(array_slice($args, 3), array_slice($args, 1, 2), array_slice($args, 0, 1));
-    return call_user_func_array('adodb_gmmktime', $args);
+  if (timeline_use_date_api() && preg_match(TIMELINE_ISO_DATE, $time, $matches)) {
+    return date_convert($time, DATE_ISO, DATE_UNIX);
   }
   return strtotime($time);
 }
