[freeside-commits] freeside/httemplate/search/elements cust_main_dayranges.html, 1.2.2.7, 1.2.2.8

Mark Wells mark at wavetail.420.am
Thu Jul 29 09:41:44 PDT 2010


Update of /home/cvs/cvsroot/freeside/httemplate/search/elements
In directory wavetail.420.am:/tmp/cvs-serv9794/httemplate/search/elements

Modified Files:
      Tag: FREESIDE_1_9_BRANCH
	cust_main_dayranges.html 
Log Message:
aging report now uses DateTime, RT#9417

Index: cust_main_dayranges.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/elements/cust_main_dayranges.html,v
retrieving revision 1.2.2.7
retrieving revision 1.2.2.8
diff -u -w -d -r1.2.2.7 -r1.2.2.8
--- cust_main_dayranges.html	22 Jul 2010 07:25:48 -0000	1.2.2.7
+++ cust_main_dayranges.html	29 Jul 2010 16:41:42 -0000	1.2.2.8
@@ -249,20 +249,25 @@
 # )
 
 sub call_range_sub {
-  my($range_sub, $start, $end, %opt) = @_;
+  my($range_sub, $startdays, $enddays, %opt) = @_;
 
-  my $as = $opt{'no_as'} ? '' : " AS rangecol_${start}_$end";
+  my $as = $opt{'no_as'} ? '' : " AS rangecol_${startdays}_$enddays";
 
   my $offset = $opt{'offset'} || 0;
-  # Time::ParseDate for excruciating correctness
   # Always use $offset - 1day + 1sec = the last second of that day
-  $start =  parsedate('00:00 '.($start + $offset - 1).' days ago') - 1;
-  $end = $end ?
-            parsedate('00:00 '.($end + $offset - 1).' days ago') - 1 : 
-            '';
-  my $cutoff = parsedate('00:00 '.($offset - 1).' days ago') - 1;
+  my $cutoff = DateTime->now->set(hour => 23, minute => 59, second => 59);
+  $cutoff->subtract(days => $offset);
 
-  my $sql = &{$range_sub}( $start, $end, $cutoff ); #%opt?
+  my $start = $cutoff->clone;
+  $start->subtract(days => $startdays);
+ 
+  my $end = $cutoff->clone;
+  $end->subtract(days => $enddays);
+
+  #warn "offset $offset (".$cutoff->epoch."), range $startdays-$enddays (".$start->epoch . '-' . ($enddays ? $end->epoch : '').")\n";
+  my $sql = &{$range_sub}( $start->epoch, 
+                           $enddays ? $end->epoch : '', 
+                           $cutoff->epoch ); #%opt?
 
   $sql = "SUM($sql)" if $opt{'sum'};
 



More information about the freeside-commits mailing list