diff options
author | mark <mark> | 2011-04-15 04:01:17 +0000 |
---|---|---|
committer | mark <mark> | 2011-04-15 04:01:17 +0000 |
commit | 7402bf45516dfe627239e7a573b1cddc39ddaf76 (patch) | |
tree | b4f25ff2667b0e4f12648d3b769be0c71a5bde31 /rt/lib/RT/Date.pm | |
parent | 2b13f96e6771617f71c57d0906387c7ce8d8dcac (diff) |
Timezone issues with this-month search, #11057
Diffstat (limited to 'rt/lib/RT/Date.pm')
-rw-r--r-- | rt/lib/RT/Date.pm | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/rt/lib/RT/Date.pm b/rt/lib/RT/Date.pm index cc66e0f5d..e68526c07 100644 --- a/rt/lib/RT/Date.pm +++ b/rt/lib/RT/Date.pm @@ -286,6 +286,8 @@ sub SetToStart { my %args = @_; my $tz = $args{'Timezone'} || ''; my @localtime = $self->Localtime($tz); + #remove 'offset' so that DST is figured based on the resulting time. + pop @localtime; # This is the cleanest way to implement it, I swear. { @@ -519,16 +521,21 @@ unix time. =cut -sub AddMonth { - require Time::ParseDate; +sub AddMonth { my $self = shift; - my $date = ( - Time::ParseDate::parsedate( - '1 month', - NOW => $self->Unix - ) - ); - return $self->Unix($date); + my %args = @_; + my @localtime = $self->Localtime($args{'Timezone'}); + # remove offset, as with SetToStart + pop @localtime; + + $localtime[4]++; #month + if ( $localtime[4] == 12 ) { + $localtime[4] = 0; + $localtime[5]++; #year + } + + my $new = $self->Timelocal($args{'Timezone'}, @localtime); + return $self->Unix($new); } =head2 Unix [unixtime] |