use local assignment to $ENV{TZ} like we do for signal handlers
authorespie <espie@openbsd.org>
Tue, 4 Jul 2023 14:41:26 +0000 (14:41 +0000)
committerespie <espie@openbsd.org>
Tue, 4 Jul 2023 14:41:26 +0000 (14:41 +0000)
usr.sbin/pkg_add/OpenBSD/PackingElement.pm

index d9d4d29..8e0481f 100644 (file)
@@ -1,5 +1,5 @@
 # ex:ts=8 sw=4:
-# $OpenBSD: PackingElement.pm,v 1.288 2023/07/04 13:58:01 espie Exp $
+# $OpenBSD: PackingElement.pm,v 1.289 2023/07/04 14:41:26 espie Exp $
 #
 # Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org>
 #
@@ -1952,14 +1952,8 @@ sub _iso8601_to_time($s)
                my ($year, $month, $day, $hour, $min, $sec) =
                    ($1 - 1900, $2-1, $3, $4, $5, $6);
                require POSIX;
-               my $oldtz = $ENV{TZ};
-               $ENV{TZ} = 'UTC';
+               local $ENV{TZ} = 'UTC';
                my $t = POSIX::mktime($sec, $min, $hour, $day, $month, $year);
-               if (defined $oldtz) {
-                       $ENV{TZ} = $oldtz;
-               } else {
-                       delete $ENV{TZ};
-               }
                return $t;
        } else {
                die "Incorrect ISO8601 timestamp: $s";