$ZHorolog

$ZH[OROLOG] returns 4 comma-separated pieces (for example, "63638,39194,258602,14400"). The first two pieces are identical to the two pieces of $HOROLOG. $ZHOROLOG is a drop-in replacement for $HOROLOG in all application code of the form $PIECE($HOROLOG,",",...). For example, $ZHOROLOG can be used as the first argument of $ZDATE(). The third piece is the number of microseconds in the current second. The accuracy of the third piece is subject to the precision of the system clock. The fourth piece is an offset in seconds to UTC. For any valid UTC time offset, the fourth piece is a number between -43200 (for UTC-12:00) and +50400 (for UTC+14:00). The value of the fourth piece remains constant all through the year except for those places that observe daylight saving time. $ZHOROLOG accuracy is subject to the precision of the system clock (use man gettimeofday from the UNIX shell for more information). To obtain the $HOROLOG representation of UTC, add the fourth piece to the second piece of $ZHOROLOG and proceed as follows:

Example:

GTM>zprint ^zhoro
zhoro(zone)
 set:'$data(zone) zone="Europe/London"
 new zutzh
 set zutzh=$$getzutzh(zone)
 do displaytzdetails(zutzh,zone)
 quit
getzutzh(zone)
  set shcommand="TZ="_zone_" $gtm_dist/mumps -run %XCMD 'write $zut,"" "",$zhorolog,"" "",$zdate($horolog,""MON DD,YYYY 12:60:SS AM""),!'"
  set descname="tzpipe"
  open descname:(shell="/bin/sh":command=shcommand:readonly)::"pipe"
  use descname read dateline use $principal close descname
  quit dateline
displaytzdetails(zutzh,zone)  
 set zut=$piece(zutzh," ",1)   ; $ZUT
 set zh=$piece(zutzh," ",2)    ; $ZHOROLOG
 set zhfp=$piece(zh,",",1)     ; first piece of $ZH of zone
 set zhsp=$piece(zh,",",2)
 set zhtp=$piece(zh,",",3)
 set zhfop=$piece(zh,",",4)
 set tz=zhfop/3600,hours=$select(tz*tz=1:" Hour ",1:" Hours ")
 write "Time in ",zone," ",$piece(zutzh," ",3,6)," $ZUT=",zut,!,$select(tz<0:-tz_hours_"Ahead of",1:tz_hours_"Behind")," UTC",!
 set zhsp=zhsp+zhfop
 if zhsp>86400 set zhfp=zhfp+1,zhsp=zhsp-86400     ; 86400 seconds in a day
 else  if zhsp<1 set zhfp=zhfp-1,zhsp=zhsp+86400
 write "Time in UTC ",$zdate(zhfp_","_zhsp,"MON DD,YYYY 12:60:SS AM")
 quit
GTM>do ^zhoro
Time in Europe/London APR 10,2015 05:20:29 PM $ZUT=1428682829213711
1 Hour Ahead of UTC
Time in UTC APR 10,2015 04:20:29 PM
GTM>