[freeside-commits] freeside/rt/lib/RT Date.pm, 1.1.1.9, 1.1.1.9.4.1 Tickets_Overlay.pm, 1.5.2.3, 1.5.2.4
Mark Wells
mark at wavetail.420.am
Fri Jan 28 13:30:19 PST 2011
Update of /home/cvs/cvsroot/freeside/rt/lib/RT
In directory wavetail.420.am:/tmp/cvs-serv7856/lib/RT
Modified Files:
Tag: FREESIDE_2_1_BRANCH
Date.pm Tickets_Overlay.pm
Log Message:
ticket search for "this month", RT#11057
Index: Date.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/rt/lib/RT/Date.pm,v
retrieving revision 1.1.1.9
retrieving revision 1.1.1.9.4.1
diff -u -w -d -r1.1.1.9 -r1.1.1.9.4.1
--- Date.pm 31 Dec 2009 13:10:15 -0000 1.1.1.9
+++ Date.pm 28 Jan 2011 21:30:16 -0000 1.1.1.9.4.1
@@ -273,6 +273,39 @@
return $self->Unix( $new );
}
+=head2 SetToStart PERIOD[, Timezone => 'utc' ]
+
+Set to the beginning of the current PERIOD, which can be
+"year", "month", "day", "hour", or "minute".
+
+=cut
+
+sub SetToStart {
+ my $self = shift;
+ my $p = uc(shift);
+ my %args = @_;
+ my $tz = $args{'Timezone'} || '';
+ my @localtime = $self->Localtime($tz);
+
+ # This is the cleanest way to implement it, I swear.
+ {
+ $localtime[0]=0;
+ last if ($p eq 'MINUTE');
+ $localtime[1]=0;
+ last if ($p eq 'HOUR');
+ $localtime[2]=0;
+ last if ($p eq 'DAY');
+ $localtime[3]=1;
+ last if ($p eq 'MONTH');
+ $localtime[4]=0;
+ last if ($p eq 'YEAR');
+ $RT::Logger->warning("Couldn't find start date of '$p'.");
+ return;
+ }
+ my $new = $self->Timelocal($tz, @localtime);
+ return $self->Unix($new);
+}
+
=head2 Diff
Takes either an C<RT::Date> object or the date in unixtime format as a string,
@@ -479,6 +512,25 @@
sub AddDay { return $_[0]->AddSeconds($DAY) }
+=head2 AddMonth
+
+Adds one month to the current time. Returns new
+unix time.
+
+=cut
+
+sub AddMonth {
+ require Time::ParseDate;
+ my $self = shift;
+ my $date = (
+ Time::ParseDate::parsedate(
+ '1 month',
+ NOW => $self->Unix
+ )
+ );
+ return $self->Unix($date);
+}
+
=head2 Unix [unixtime]
Optionally takes a date in unix seconds since the epoch format.
Index: Tickets_Overlay.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/rt/lib/RT/Tickets_Overlay.pm,v
retrieving revision 1.5.2.3
retrieving revision 1.5.2.4
diff -u -w -d -r1.5.2.3 -r1.5.2.4
--- Tickets_Overlay.pm 26 Jan 2011 21:43:14 -0000 1.5.2.3
+++ Tickets_Overlay.pm 28 Jan 2011 21:30:16 -0000 1.5.2.4
@@ -540,10 +540,21 @@
# particular single day. in the database, we need to check for >
# and < the edges of that day.
+ my ($daystart, $dayend);
+ if ( lc($value) eq 'this month' ) {
+ # special case: > and < the edges of this month
+ $date->SetToNow;
+ $date->SetToStart('month');
+ $daystart = $date->ISO;
+ $date->AddMonth;
+ $dayend = $date->ISO;
+ }
+ else {
$date->SetToMidnight( Timezone => 'server' );
- my $daystart = $date->ISO;
+ $daystart = $date->ISO;
$date->AddDay;
- my $dayend = $date->ISO;
+ $dayend = $date->ISO;
+ }
$sb->_OpenParen;
More information about the freeside-commits
mailing list