? 740296-reports-time.patch
Index: uc_reports.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ubercart/uc_reports/uc_reports.admin.inc,v
retrieving revision 1.1.2.16
diff -u -p -r1.1.2.16 uc_reports.admin.inc
--- uc_reports.admin.inc	18 Mar 2010 03:09:41 -0000	1.1.2.16
+++ uc_reports.admin.inc	20 Mar 2010 06:59:43 -0000
@@ -638,20 +638,29 @@ function theme_uc_reports_product_table(
  * Display the sales summary report.
  */
 function uc_reports_sales_summary() {
-  $timezone_offset = time() + _uc_reports_timezone_offset();
-  $order_statuses = _uc_reports_order_statuses();
-  $format = variable_get('uc_date_format_default', 'm/d/Y');
+  // "Now" timestamp
+  $time = time();
 
-  $date_month = gmdate('n', $timezone_offset);
-  $date_year = gmdate('Y', $timezone_offset);
-  $date_day_of_month = gmdate('j', $timezone_offset);
-  $date_days_in_month = gmdate('t', $timezone_offset);
+  // Site time minus GMT time, in seconds
+  $timezone_offset = _uc_reports_timezone_offset();
 
-  $month_start = gmmktime(0, 0, 0, $date_month, 1, $date_year);
-  $month_end = gmmktime(23, 59, 59, $date_month, $date_days_in_month, $date_year);
+  // Find day/month/year of "Now" in site timezone
+  $date_month = format_date($time, 'custom', 'n', $timezone_offset);
+  $date_year = format_date($time, 'custom', 'Y', $timezone_offset);
+  $date_day_of_month = format_date($time, 'custom', 'j', $timezone_offset);
+  $date_days_in_month = format_date($time, 'custom', 't', $timezone_offset);
+
+  // Calculate Unix timecodes (defined to be in GMT time)
+  // for beginning and ending of reporting periods
+  // Use gm functions so PHP won't try to do any timezone conversions by itself
+  $month_start = gmmktime(0, 0, 0, $date_month, 1, $date_year) - $timezone_offset;
+  $month_end = gmmktime(23, 59, 59, $date_month, $date_days_in_month, $date_year) - $timezone_offset;
+  $today_start = gmmktime(0, 0, 0, $date_month, $date_day_of_month, $date_year) - $timezone_offset;
+  $today_end = gmmktime(23, 59, 59, $date_month, $date_day_of_month, $date_year) - $timezone_offset;
 
-  $today_start = gmmktime(0, 0, 0, $date_month, $date_day_of_month, $date_year);
-  $today_end = gmmktime(23, 59, 59, $date_month, $date_day_of_month, $date_year);
+  // Initialize variables used later
+  $order_statuses = _uc_reports_order_statuses();
+  $format = variable_get('uc_date_format_default', 'm/d/Y');
 
   // Build the report table header.
   $header = array(t('Sales data'), t('Number of orders'), t('Total revenue'), t('Average order'));
