IBM Support

AIX Time Zone: Sample Perl script to test TZ changes without impacting the system time

Question & Answer


Question

How can I test upcoming TZ changes without impacting my production system?

Answer

This document provides a custom, unsupported test that uses a third-party Perl module to test alternative system times. The actual system time is not affected.
NOTE:  
Custom modules installed to the AIX perl.rte installation are not migrated in newer perl.rte updates. AIX Support recommends that you develop and test Perl applications with the latest version available on the AIX Toolbox, which installs Perl in a unique path, to ensure the most prompt availability of latest Perl releases, and control over custom modules.
Steps:
1) Install the Perl Time::Fake module from MetaCPAN.
### Tip  - Set data ulimit to unlimited to avoid memory errors
# ulimit -d unlimited
# perl64 -MCPAN -e shell
cpan[1]> install Time::Fake
<....>
  ROSULEK/Time-Fake-0.11.tar.gz
  /usr/bin/make install  -- OK

cpan[2]>quit
2) Create a Perl script "tzTest.pl"
# cat tzTest.pl
use POSIX qw(strftime);
my $bdate = strftime "%a %b %e %H:%M:%S %Z %Y", localtime();

 
print "Before Date Change:\t", $bdate, "\n";
my $adate = strftime "%a %b %e %H:%M:%S %Z %Y", localtime(time+61);
print "After Date Change:\t", $adate, "\n";

 
3) Run the script with appropriate localtime values for your time zone test.
# perl -MTime::Fake=`perl -e 'use Time::Local; print timelocal(00,00,02,12,02,123), "\n";'`  ./tzTest.pl
Tips for Perl localtime values:
The documented example uses the 0-6 array of Perl localtime

 # 0  1    2     3     4    5     6     7     8
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
NOTE: 
$month range is 0-11, where January is 0.
$year is the number of years since 1900
The following example used the US America/Chicago time zone, which changes to DST on March 12, at 02:00 AM. Next, it tests Tijuana, which switches to DST on the same date.  Finally, it tests Mexico City, which formerly switched to DST on the first Sunday, but disabled DST in the fall of 2022.
# export TZ=America/Chicago
#perl -MTime::Fake=`perl -e 'use Time::Local; print timelocal(00,59,01,12,02,123), "\n";'` ./tzTest.pl
Before Date Change:     Sun Mar 12 01:59:00 CST 2023
After Date Change:      Sun Mar 12 03:00:01 CDT 2023

 
# export TZ=America/Tijuana
# perl -MTime::Fake=`perl -e 'use Time::Local; print timelocal(00,59,01,12,02,123), "\n";'` ./tzTest.pl
Before Date Change:     Sun Mar 12 01:59:00 PST 2023
After Date Change:      Sun Mar 12 03:00:01 PDT 2023

 
# export TZ=America/Mexico_City
# perl -MTime::Fake=`perl -e 'use Time::Local; print timelocal(00,59,01,02,03,123), "\n";'` ./tzTest.pl
Before Date Change:     Sun Apr  2 01:59:00 CST 2023
After Date Change:      Sun Apr  2 02:00:01 CST 2023

 

 
SUPPORT

NOTE:  CPAN Modules are not supported by AIX Support.  If you have issues with the module, refer to the module support details on the MetaCPAN download page.

If you require more AIX time zone assistance, use the following step-by-step instructions to contact IBM to open a case for software with an active and valid support contract.  

1.  Document (or collect screen captures of) all symptoms, errors, and messages related to your issue.

2.  Capture any logs or data relevant to the situation.

3.  Contact IBM to open a case:

   -For electronic support, see the IBM Support Community:
     https://www.ibm.com/mysupport
   -If you require telephone support, see the web page:
      https://www.ibm.com/planetwide/

4.  Provide a clear, concise description of the issue.

5.  If the system is accessible, collect a system snap, and upload all of the details and data for your case.

 - See Working with IBM AIX Support: Collecting snap data

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG10","label":"AIX"},"ARM Category":[{"code":"a8m50000000L0QaAAK","label":"Commands-\u003ETime Zone"}],"ARM Case Number":"","Platform":[{"code":"PF002","label":"AIX"}],"Version":"All Versions","Edition":"","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]

Document Information

Modified date:
20 March 2023

UID

ibm16963340