? 341920-signup-date.sql
? 341920_no_date_hacks.6.d6.patch
? 582986-2.signup_require_views.patch
? 582986-3.signup_require_views.patch
? 865108_signup_1_typo.patch
? date.inc_1.patch
? signup-670944-1.patch
? signup-HEAD_admin_details_username_0.patch
? signup.858592_0.patch
? signup.empty_date20090815.patch
? signup_adminlistfix.patch
? views/723552-username.patch
Index: includes/date.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/signup/includes/date.inc,v
retrieving revision 1.16.2.7
diff -u -p -r1.16.2.7 date.inc
--- includes/date.inc	28 Dec 2010 19:59:57 -0000	1.16.2.7
+++ includes/date.inc	28 Dec 2010 23:31:38 -0000
@@ -303,7 +303,7 @@ function _signup_date_reminder_sql($cont
   // Figure out what TZ we want to do the date comparisons in.
   $compare_tz = $field['tz_handling'] == 'none' ? date_default_timezone_name() : 'UTC';
   // Get a DateAPI SQL handler class for this field.
-  $handler = _signup_date_sql_handler($field, $compare_tz);
+  $handler = date_field_get_sql_handler($field, $compare_tz);
 
   // Find the current time in the appropriate TZ for this field.
   $now_date = date_now($compare_tz);
@@ -315,8 +315,8 @@ function _signup_date_reminder_sql($cont
 
   // Create SQL to represent the time we should start sending reminders, based
   // on the SQL for the start time and the reminder_days_before field.
-  $reminder_start = _signup_date_sql_math($start_time, 'SUB', 's.reminder_days_before', 'DAY');
-  $reminder_stop = _signup_date_sql_math($start_time, 'ADD', 1, 'HOUR');
+  $reminder_start = $handler->sql_date_math($start_time, 'SUB', 's.reminder_days_before', 'DAY');
+  $reminder_stop = $handler->sql_date_math($start_time, 'ADD', 1, 'HOUR');
 
   // The WHERE clauses are now trivial: We want to make sure a) the current
   // time is after the time we should start sending reminders, but before the
@@ -351,7 +351,7 @@ function _signup_date_autoclose_sql($con
   // Figure out what TZ we want to do the date comparisons in.
   $compare_tz = $field['tz_handling'] == 'none' ? date_default_timezone_name() : 'UTC';
   // Get a DateAPI SQL handler class for this field.
-  $handler = _signup_date_sql_handler($field, $compare_tz);
+  $handler = date_field_get_sql_handler($field, $compare_tz);
 
   // Compute a string representing the moment when signups should start
   // auto-closing.  If the field has no TZ handling, we just want to grab the
@@ -381,89 +381,6 @@ function _signup_date_autoclose_sql($con
 }
 
 /**
- * Generate a DateAPI SQL handler for the given CCK date field.
- *
- * This can be removed once revision 1.61.2.4.2.32 is widely available in an
- * official release.
- */
-function _signup_date_sql_handler($field, $compare_tz = NULL) {
-  // Workaround for a bug in DateAPI upto 6.x-2.0-rc5.
-  static $mysql_db_offset_set = FALSE;
-  module_load_include('inc', 'date_api', 'date_api_sql');
-
-  // Create a DateAPI SQL handler class for this field type.
-  $handler = new date_sql_handler();
-  $handler->construct($field['type']);
-
-  // If this date field stores a timezone in the DB, tell the handler about it.
-  if ($field['tz_handling'] == 'date') {
-    // The field has a date column
-    $handler->db_timezone_field = $field['database']['columns']['timezone']['column'];
-  }
-  else {
-    $handler->db_timezone = date_get_timezone_db($field['tz_handling']);
-  }
-
-  if (empty($compare_tz)) {
-    $compare_tz = date_get_timezone($field['tz_handling']);
-  }
-  $handler->local_timezone = $compare_tz;
-
-  // Now that the handler is properly initialized, tell the DB what TZ to use.
-  $handler->set_db_timezone();
-
-  // Up to and including DateAPI 6.x-2.0-rc5, the previous call only worked
-  // for mysqli and pgsql. It was a no-op on mysql itself, so in that case, we
-  // have to do the work ourselves here or datestamp fields don't work.
-  if ($GLOBALS['db_type'] == 'mysql' && !$mysql_db_offset_set && version_compare(db_version(), '4.1.3', '>=')) {
-    db_query("SET @@session.time_zone = '+00:00'");
-    $mysql_db_offset_set = TRUE;
-  }
-
-  return $handler;
-}
-
-/**
- * Helper function to handle date math across DB types.
- *
- * This can be removed once date_api_sql.inc revision 1.9.2.3.2.28 is widely
- * available in an official release.
- *
- * @param $field
- *   The field to be adjusted.
- * @param $direction
- *   Either ADD or SUB.
- * @param $count
- *   The number of values to adjust.
- * @param $granularity
- *   The granularity of the adjustment, should be singular,
- *   like SECOND, MINUTE, DAY, HOUR.
- */
-function _signup_date_sql_math($field, $direction, $count, $granularity) {
-  $granularity = strtoupper($granularity);
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      if ($direction == 'ADD') {
-        return "DATE_ADD($field, INTERVAL $count $granularity)";
-      }
-      else {
-        return "DATE_SUB($field, INTERVAL $count $granularity)";
-      }
-      
-    case 'pgsql':
-      $granularity .= 'S';
-      if ($direction == 'ADD') {
-        return "($field + INTERVAL '$count $granularity')";
-      }
-      else {
-        return "($field - INTERVAL '$count $granularity')";
-      }
-  }
-  return $field;
-}
-
-/**
  * Returns TRUE if the given node is event-enabled, and the start time
  * has already passed the "Close x hours before" setting.
  */
