Index: bouncer.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/bouncer/bouncer.module,v
retrieving revision 1.12
diff -u -p -r1.12 bouncer.module
--- bouncer.module	9 Jul 2008 06:21:42 -0000	1.12
+++ bouncer.module	19 Oct 2008 20:10:39 -0000
@@ -265,24 +265,45 @@ function bouncer_url($url, $context=NULL
  * The summary view form
  */
 function bouncer_report_summary_form() {
-  date_load('date.inc');
+  if (function_exists('date_load')) {
+    date_load('date.inc');
+    $date_v2=FALSE;
+  } else {
+    $date_v2=TRUE;
+  }
   $form=array();
 
   $form['#tree']=TRUE;
 
-  $params = array('label' => t('Start date'),
-                  'granularity' => array('Y', 'M', 'D', 'T'),
-                  'text_parts' => array(),
-                  'weight' => 0,
-                  'year_range' => '3:0',
-  );
-  $form['start_date'] = date_select_input($params);
-  $params['label']=t('End date');
-  $params['weight']=1;
-  $form['end_date'] = date_select_input($params);
-  $params['label']=t('Date');
-  $params['weight']=2;
-  $form['tz'] = date_timezone_input($params);
+  if (!$date_v2) {
+    $params = array('label' => t('Start date'),
+                    'granularity' => array('Y', 'M', 'D', 'T'),
+                    'text_parts' => array(),
+                    'weight' => 0,
+                    'year_range' => '3:0',
+    );
+    $form['start_date'] = date_select_input($params);
+    $params['label']=t('End date');
+    $params['weight']=1;
+    $form['end_date'] = date_select_input($params);
+    $params['label']=t('Date');
+    $params['weight']=2;
+    $form['tz'] = date_timezone_input($params);
+  } else {
+    $params = array('#title' => t('Start date'),
+                    '#type' => 'date_select',
+                    '#date_format' => 'ymd',
+                    '#weight' => 0,
+                    '#date_year_range' => '-3:0',
+    );
+    $form['start_date']=$params;
+    $params['#weight']=1;
+    $params['#title']=t('End date');
+    $form['end_date']=$params;
+    $form['tz'] = array('#title' => t('Time zone'),
+                        '#type' => 'date_timezone',
+                        '#weight' => 2);
+  }
 
   $form['group_by']=array('#type' => 'select',
                           '#title' => t('Group summary by'),
@@ -312,26 +333,44 @@ function bouncer_report_summary_form() {
 }
 
 function bouncer_report_summary_result() {
-  date_load('date.inc');
-  $form=array();
-
+  // use 'small' date format
+  $format = variable_get('date_format_short', 'm/d/Y - H:i');
   $tz=$_GET['tz'];
 
-  $start_date=date_make_date($_GET['start_date'], $tz, 'local', DATE_ISO);
-  $end_date=date_make_date($_GET['end_date'], $tz, 'local', DATE_ISO);
+  $form=array();
+
+  $date_v2=!function_exists('date_load');
+  if (!$date_v2) {
+    date_load('date.inc');
+    $start_date=date_make_date($_GET['start_date'], $tz, 'local', DATE_ISO);
+    $end_date=date_make_date($_GET['end_date'], $tz, 'local', DATE_ISO);
+
+    $start_timestamp=date_show_value($start_date, 'db', DATE_UNIX);
+    $end_timestamp=date_show_value($end_date, 'db', DATE_UNIX);
+
+    // header
+    $form['time_window']=array('#title' => t('Time window'),
+                               '#type' => 'item',
+                               '#value' => check_plain(date_show_date($start_date, $format, 'local')) .
+                               ' &mdash; '.check_plain(date_show_date($end_date, $format, 'local').
+                                                       check_plain(" ($tz)")));
+  } else {
+    $start_timestamp=$_GET['start_date'];
+    $end_timestamp=$_GET['end_date'];
+
+    $start_date=date_make_date($start_timestamp, $tz, DATE_UNIX);
+    $end_date=date_make_date($end_timestamp, $tz, DATE_UNIX);
+
+    // header
+    $form['time_window']=array('#title' => t('Time window'),
+                               '#type' => 'item',
+                               '#value' => check_plain(date_format_date($start_date, 'medium')) .
+                               ' &mdash; '.check_plain(date_format_date($end_date, 'medium').
+                                                       check_plain(" ($tz)")));
+  }
 
-  $start_timestamp=date_show_value($start_date, 'db', DATE_UNIX);
-  $end_timestamp=date_show_value($end_date, 'db', DATE_UNIX);
 
-  // use 'small' date format
-  $format = variable_get('date_format_short', 'm/d/Y - H:i');
 
-  // header
-  $form['time_window']=array('#title' => t('Time window'),
-                       '#type' => 'item',
-                             '#value' => check_plain(date_show_date($start_date, $format, 'local')) .
-                             ' &mdash; '.check_plain(date_show_date($end_date, $format, 'local').
-                                               check_plain(" ($tz)")));
   $context=$_GET['context'];
   if ($context!==NULL) {
     $form['context']=array('#title' => t('Redirecting context'),
@@ -419,19 +458,32 @@ function theme_bouncer_summary_pager($ta
 }
 
 function bouncer_report_summary_form_submit($form_id, $form) {
-  $date_start=date_selector_make_dbdate($form['start_date'], DATE_ISO, $form['tz']['timezone']);
+  $date_v2=!function_exists('date_load');
+  if (!$date_v2) {
+    $date_start=date_selector_make_dbdate($form['start_date'], DATE_ISO, $form['tz']['timezone']);
 
   
-  $date_end=date_selector_make_dbdate(array_merge($form['end_date'],
-                                                  array('hours'=>23, 'minutes'=>59, 'seconds'=>59)),
-                                      DATE_ISO,
-                                      $form['tz']['timezone'],
-                                      array('Y', 'M', 'D', 'H', 'N', 'S'));
+    $date_end=date_selector_make_dbdate(array_merge($form['end_date'],
+                                                    array('hours'=>23, 'minutes'=>59, 'seconds'=>59)),
+                                        DATE_ISO,
+                                        $form['tz']['timezone'],
+                                        array('Y', 'M', 'D', 'H', 'N', 'S'));
+    $query='start_date='.urlencode(date_show_value($date_start, 'local', DATE_ISO));
+    $query.='&end_date='.urlencode(date_show_value($date_end, 'local', DATE_ISO));
+    $query.='&tz='.urlencode($form['tz']['timezone']);
+  } else {
+    $date_start = date_make_date($form['start_date'], $form['tz'], DATE_ISO);
+    $date_end = date_make_date($form['end_date'], $form['tz'], DATE_ISO);
+
+    date_timezone_set($date_start, timezone_open('UTC'));
+    date_timezone_set($date_end, timezone_open('UTC'));
+    
+    $query='start_date='.urlencode(date_format_date($date_start, 'custom', DATE_FORMAT_UNIX));
+    $query.='&end_date='.urlencode(date_format_date($date_end, 'custom', DATE_FORMAT_UNIX));
+    $query.='&tz='.urlencode($form['tz']);
+  }
 
  
-  $query='start_date='.urlencode(date_show_value($date_start, 'local', DATE_ISO));
-  $query.='&end_date='.urlencode(date_show_value($date_end, 'local', DATE_ISO));
-  $query.='&tz='.urlencode($form['tz']['timezone']);
   $query.='&group_by='.urlencode($form['group_by']);
   if ($form['context']!='NULL') {
     $query.='&context='.urlencode($form['context']);
