MPE/iX Time

Time keeping on MPE seems rather complicated. Let me attempt to simplify it. Internally MPE keeps time as GMT (Greenwich Mean Time), also known as UTC (Universal Time or Coordinated Universal Time). This is the only clock MPE keeps and is often referred to as the hardware clock. Local time is calculated based upon the TIMEZONE offset specified using the SETCLOCK command.

MPE commands such as SHOWTIME and LISTF, as well as intrinsics like CLOCK obtain the current time of day using the GMT plus or minus the timezone offset. This calculated local time is frequently called the software clock. Twice a year the timezone offset must be adjusted using SETCLOCK. Systems that are automated to reset the TIMEZONE on the correct dates must be adjusted to deal with this change. As an example we have an HP3000 that schedules a time change job for every Sunday at 2:00 AM. The job contains logic to determine if this is the correct day to adjust the timezone. The logic in this job will have to be modified for the new rules. The new job looks like this:

!job timechg,manager/xxxxx.sys/yyyyy;outclass=lp,1
!tellop timechg:  Checks for DST begin or end and adjusts as needed.
!comment
!comment  This job should be streamed every Sunday morning at
!comment  2:00 AM. On the appropriate days of the year it will
!comment  adjust the timezone parameter to either Eastern Standard
!comment  time (W5:00) or Eastern Daylight Savings Time (W4:00)
!comment
!comment  Note:  All time changes are gradual. It could take
!comment         several hours for the actual system time to
!comment         become correct. To see  the progress of the
!comment         time correction use the :SHOWCLOCK command.
!comment
!comment      Job courtesy Beechglen Development Inc.
!comment                   Cincinnati, Ohio
!comment                   http://www.beechglen.com
!comment
!comment  -------------------------------------------------
!comment  Configure parameters here
!comment
!comment  Set the appropriate timezone offset for standard
!comment  and daylight savings time. Examples for US zones:
!comment
!comment   Zone       Std Offset    DST offset
!comment   Eastern    w5:00         w4:00
!comment   Central    w6:00         w5:00
!comment   Mountain   w7:00         w6:00
!comment   Pacific    w8:00         w7:00
!comment
!setvar STDOffset,"w5:00"
!setvar DSTOffset,"w4:00"
!comment
!comment  -------------------------------------------------
!if hpday <> 1 then
!   comment job is only supposed to be scheduled on a Sunday
!   eoj
!endif
!tellop  **************************************************
!tellop  **   Checking for possible time change.         **
!tellop  **************************************************
!showclock
!run showclks.pubxl.telesup
!if hpmonth = 11 and hpdate < 8 then
!   comment First Sunday in November, Daylight Savings Time ends.
!   setclock timezone=!STDOffset
!   tellop  **************************************************
!   tellop  **   Daylight Savings Ends. Begin Standard Time **
!   tellop  **   TIME adjustment in progress.               **
!   tellop  **************************************************
!elseif hpmonth = 3 and hpdate > 7 and hpdate < 15 then
!   comment  Second Sunday in March, Daylight Savings Time begins.
!   setclock timezone=!DSTOffset
!   tellop  **************************************************
!   tellop  **   Standard time Begins. Daylight Savings     **
!   tellop  **   ends. TIME adjustment in progress.         **
!   tellop  **************************************************
!else
!   tellop  **************************************************
!   tellop  **   No time change necessary.                  **
!   tellop  **************************************************
!endif
!showclock
!run showclks.pubxl.telesup
:eoj

On the other hand, utilities that use the C library functions to get the current time operate differently. C functions are callable routines just like MPE intrinsics. Examples of applications that use the C library are the Posix shell, any ported Posix tools such as sendmail, Samba, Apache, and Syslog. Likewise, Cognos Powerhouse, Suprtool, and the Cobol85 function CURRENT-DATE call the the C library functions to get the current date and time. The C function ‘ctime’ obtains the current time GMT and then automatically applies the correct offset based on a table kept in the file TZTAB.LIB.SYS. In order to find the correct table entry the TZ variable must be set telling the system what the local time zone is. If no TZ variable is set MPE defaults to Eastern Time using the value ‘EST5EDT’. The great thing about this method is that the time zone need not be adjusted twice a year. Once the correct TZ variable is set the transitions into and out of Daylight Savings Time occur automatically. The only time an adjustment is necessary is when the rules for DST change.

The MPE TZTAB file can be found here in ASCII format. Or click here to download a copy of TZTAB and the sample job listed above. A simple ASCII file transfer to the HP is all that is needed

The latest version of TZTAB.LIB.SYS, released 3/5/2007, has an EOF of 670 records. As long as your TZTAB file contains 670 records do not worry that the previous version was 1276 byte variable ASCII and the new one is 80 bytes or 252 bytes wide.


Time Problems and Fixes Encountered

SHOWCLKS.PUBXL.TELESUP reports systems in Eastern Time Zone still off by 1 hour even with new TZTAB file in place. This occurs when there isn’t a TZ variable set. MPE has always defaulted to the timezone setting EST5EDT when no TZ variable was explicitly set. But these rules were hardcoded in the ctime function rather than obtaining the information from TZTAB. If Cobol programs using FUNCTION CURRENT-DATE or Cognos Powerhouse programs are reporting the wrong time you must explicitly set the TZ variable in your system-wide logon UDC by including the command

SETVAR TZ,"EST5EDT"

The next time the users log on or batch jobs are streamed they will pick up the correct offset. Other timezones where the TZ variable is explicitly set should be unaffected by this behavior.The Posix shell date command and other programs such as sendmail that obtain the date from the shell are not picking up the tztab changes. The fix for this is to explicitly set timezone information into the tztab variable by adding one of the following entries into the file /etc/profile.local based upon the proper time zone:


Eastern : export TZ="EST5EDT4,M3.2.0/02:00,M11.1.0/02:00"
Central : export TZ="CST6CDT5,M3.2.0/02:00,M11.1.0/02:00"
Mountain: export TZ="MST7MDT6,M3.2.0/02:00,M11.1.0/02:00"
Pacific : export TZ="PST8PDT7,M3.2.0/02:00,M11.1.0/02:00"

This fix works by loading the actual month/day of week/week of month/time of day the time change occurs in the TZ variable. This is a standard method of loading data into the TZ variable that is supported on most variations of Posix/Unix. Enter "man timezone" in the Posix shell for further explanation.