%TIMEZONE
Return the time zone of the current machine
WSupported on Windows
|
USupported on Unix
|
VSupported on OpenVMS
|
NSupported in Synergy .NET
|
offset = %TIMEZONE([timezone][, daylight])
Return value
offset
The number of minutes east of the Greenwich Meridian. (n)
Arguments
timezone
(optional) Returned with the name of the current time zone as defined on the local system. (a)
For example,
- On Windows, Eastern Standard Time, Eastern Daylight Time, Pacific Standard Time, Pacific Daylight Time, GMT Daylight Time, and so forth.
- On Unix and OpenVMS, EST, EDT, PST, PDT, GMT, and so forth.
daylight
(optional) Returned with one of the following daylight saving time flags: (n)
0 = Daylight saving time is not in effect.
nonzero = Daylight saving time is in effect.
Discussion
%TIMEZONE returns the number of minutes east of the Greenwich Meridian in which the current machine is located and optionally returns the name of the current time zone and/or whether daylight saving time is in effect. For example, if the current time is 5 hours west of Greenwich, the offset value would be -300. If the current time is 3 hours east of Greenwich, offset would be 180.
You can use %TIMEZONE as an argument to %DATETIME.
When a particular time zone supports daylight saving time and the daylight flag is not zero, add 60 minutes to the returned offset to get the correct local time when passed to %DATETIME. (See Examples below.) |
See also
%DATETIME routine
Examples
The example below adds 60 minutes to the offset to account for daylight saving time.
record group dt ,a20 group date ,a8 year ,a4 month ,a2 day ,a2 endgroup group time ,a12 hour ,a2 minute ,a2 second ,a2 msecond ,a6 endgroup endgroup dst ,d1 gmtoffset ,i4 proc open(1, O, "TT:") gmtoffset = %timezone(, DST) if (dst) gmtoffset += 60 ;CA to GMT is -300 but when DST is enabled needs to be -240 dt = %datetime(gmtoffset) writes(1, "Time = " + hour + ":" + minute + " DST " + %string(dst)) shell(,"start https://www.google.com/search?q=utc+time",D_NOWINDOW) close 1 endmain