[Bps-public-commit] RT-Extension-SLA branch, per-queue-timezones, updated. 0.05-13-g6ce36a9
Ruslan Zakirov
ruz at bestpractical.com
Wed May 30 16:19:15 EDT 2012
The branch, per-queue-timezones has been updated
via 6ce36a970e9e5fc36f4666084be033d5701a25d3 (commit)
via 4aa35ceb8c3ba44ec6dd047a444ea116e1c03dd4 (commit)
from 564d150ec6c76bc9f68924a3e991dfe575d0b544 (commit)
Summary of changes:
lib/RT/Extension/SLA.pm | 50 ++++++++++++++++++++++++++++-------------------
t/basics.t | 2 +-
2 files changed, 31 insertions(+), 21 deletions(-)
- Log -----------------------------------------------------------------
commit 4aa35ceb8c3ba44ec6dd047a444ea116e1c03dd4
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Thu May 31 00:16:25 2012 +0400
adjust number of tests
diff --git a/t/basics.t b/t/basics.t
index f9e9ed7..4583112 100644
--- a/t/basics.t
+++ b/t/basics.t
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use RT::Extension::SLA::Test tests => 4, nodb => 1;
+use RT::Extension::SLA::Test tests => 1, nodb => 1;
use_ok 'RT::Extension::SLA';
commit 6ce36a970e9e5fc36f4666084be033d5701a25d3
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Thu May 31 00:16:58 2012 +0400
make sure timezone change is seen by system functions
On some systems value of TZ is cached by functions
and we have to call POSIX::tzset to flush the cahce.
diff --git a/lib/RT/Extension/SLA.pm b/lib/RT/Extension/SLA.pm
index 8d02ca2..4cd3a92 100644
--- a/lib/RT/Extension/SLA.pm
+++ b/lib/RT/Extension/SLA.pm
@@ -406,32 +406,42 @@ sub CalculateTime {
my $agreement = $self->Agreement( @_ );
return undef unless $agreement;
- local $ENV{'TZ'} = $ENV{'TZ'};
- $ENV{'TZ'} = $agreement->{'Timezone'} if $agreement->{'Timezone'};
-
- my $bhours = $self->BusinessHours( $agreement->{'BusinessHours'} );
-
my $res = $args{'Time'};
- if ( $agreement->{'OutOfHours'} && $bhours->first_after( $res ) != $res ) {
- foreach ( qw(RealMinutes BusinessMinutes) ) {
- next unless my $mod = $agreement->{'OutOfHours'}{ $_ };
- ($agreement->{ $_ } ||= 0) += $mod;
+ my $ok = eval {
+ local $ENV{'TZ'} = $ENV{'TZ'};
+ if ( $agreement->{'Timezone'} && $agreement->{'Timezone'} ne ($ENV{'TZ'}||'') ) {
+ $ENV{'TZ'} = $agreement->{'Timezone'};
+ require POSIX; POSIX::tzset();
}
- }
- if ( defined $agreement->{'BusinessMinutes'} ) {
- if ( $agreement->{'BusinessMinutes'} ) {
- $res = $bhours->add_seconds(
- $res, 60 * $agreement->{'BusinessMinutes'},
- );
+ my $bhours = $self->BusinessHours( $agreement->{'BusinessHours'} );
+
+ if ( $agreement->{'OutOfHours'} && $bhours->first_after( $res ) != $res ) {
+ foreach ( qw(RealMinutes BusinessMinutes) ) {
+ next unless my $mod = $agreement->{'OutOfHours'}{ $_ };
+ ($agreement->{ $_ } ||= 0) += $mod;
+ }
}
- else {
- $res = $bhours->first_after( $res );
+
+ if ( defined $agreement->{'BusinessMinutes'} ) {
+ if ( $agreement->{'BusinessMinutes'} ) {
+ $res = $bhours->add_seconds(
+ $res, 60 * $agreement->{'BusinessMinutes'},
+ );
+ }
+ else {
+ $res = $bhours->first_after( $res );
+ }
}
- }
- $res += 60 * $agreement->{'RealMinutes'}
- if defined $agreement->{'RealMinutes'};
+ $res += 60 * $agreement->{'RealMinutes'}
+ if defined $agreement->{'RealMinutes'};
+ 1;
+ };
+
+ POSIX::tzset() if $agreement->{'Timezone'}
+ && $agreement->{'Timezone'} ne ($ENV{'TZ'}||'');
+ die $@ unless $ok;
return $res;
}
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list