[Rt-commit] r8524 - rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT

ruz at bestpractical.com ruz at bestpractical.com
Mon Aug 13 20:40:13 EDT 2007


Author: ruz
Date: Mon Aug 13 20:40:13 2007
New Revision: 8524

Modified:
   rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Date.pm

Log:
* on systems where we must call tzset we must call it twice,
  first time when we set TZ using local and second time when
  it's restored

Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Date.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Date.pm	(original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Date.pm	Mon Aug 13 20:40:13 2007
@@ -778,11 +778,14 @@
     if ($tz eq 'UTC') {
         @local = gmtime($unix);
     } else {
-        local $ENV{'TZ'} = $tz;
-	## Using POSIX::tzset fixes a bug where the TZ environment variable
-	## is cached.
-	POSIX::tzset();
-        @local = localtime($unix);
+        {
+            local $ENV{'TZ'} = $tz;
+            ## Using POSIX::tzset fixes a bug where the TZ environment variable
+            ## is cached.
+            POSIX::tzset();
+            @local = localtime($unix);
+        }
+        POSIX::tzset(); # return back previouse value
     }
     $local[5] += 1900; # change year to 4+ digits format
     my $offset = Time::Local::timegm_nocheck(@local) - $unix;
@@ -814,14 +817,19 @@
         return timegm(@_[0..5]) - $_[9];
     } else {
         $tz = $self->Timezone( $tz );
-        if ($tz eq 'UTC') {
+        if ( $tz eq 'UTC' ) {
             return Time::Local::timegm(@_[0..5]);
         } else {
-            local $ENV{'TZ'} = $tz;
-	    ## Using POSIX::tzset fixes a bug where the TZ environment variable
-	    ## is cached.
-	    POSIX::tzset();
-            return Time::Local::timelocal(@_[0..5]);
+            my $rv;
+            {
+                local $ENV{'TZ'} = $tz;
+                ## Using POSIX::tzset fixes a bug where the TZ environment variable
+                ## is cached.
+                POSIX::tzset();
+                $rv = Time::Local::timelocal(@_[0..5]);
+            };
+            POSIX::tzset(); # switch back to previouse value
+            return $rv;
         }
     }
 }


More information about the Rt-commit mailing list