$ZF(-100 - returning terminal output. Or, daylight savings time

304 views
Skip to first unread message

Michoel Reach

unread,
May 25, 2021, 2:23:24 PM5/25/21
to IRIS, Caché, Ensemble
I was trying to get the computer's time zone programmatically. In my case it could be Eastern Daylight Time, or Eastern Standard Time, and it varies with the time of year.
In Windows, you can ask at the Command Prompt
> tzutil /g
Eastern Standard Time
>
So from inside ObjectScript, I can call
set x=$ZF(-1,"tzutil /g") to run the code.
However, x is set to the status code (like 0), not the correct output.
I can direct the output to a file
set x=$ZF(-1,"tzutil /g > timezone.txt")
and then open the file and read it, and that works.
But is there a way to just grab the output and return that as the result?
2) I tried this with $ZF(-100 since the documentation says that $ZF(-1 is deprecated in favor of $ZF(-100, but I got a <NOTOPEN> error no matter how I set the flags. How should this be called?
3) Is there some simpler way to get the time zone from within Cache' itself?
Thanks!
Michael Reach
[Cache for Windows (x86-64) 2018.1.4 (Build 505_1_20258U) Thu Sep 10 2020 10:22:2
2 EDT]

Ed Clark

unread,
May 25, 2021, 3:58:44 PM5/25/21
to intersystems...@googlegroups.com
There are some suggestions for this on the developer community:

There are some one-liner method in classes that you can use as examples, though the classes themselves are identified as “internal” and not guaranteed not to change:
%Studio.SourceControl.ISC.SecureRunCmd()

$zf(-100) can be used like this:
s tf=##class(%File).TempFilename(),fp=##class(%File).%New(tf)
s cmd="tzutil",arg(1)="/g"
d $zf(-100,"/SHELL /STDOUT="""_tf_"""",cmd,.arg)
d fp.Open("R")
d fp.OutputToDevice()
d ##class(%File).Delete(tf)



--
--
IRIS, Caché, Ensemble
---
You received this message because you are subscribed to the Google Groups "IRIS, Caché, Ensemble" group.
To unsubscribe from this group and stop receiving emails from it, send an email to intersystems-publi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/intersystems-public-cache/a4f5d55c-d24b-463d-bf93-c5dc287b6788n%40googlegroups.com.

Michoel Reach

unread,
May 25, 2021, 4:01:10 PM5/25/21
to IRIS, Caché, Ensemble
Note that there is $ZTIMEZONE, but the documentation says that it does not take Daylight Savings Time into account.

Michoel Reach

unread,
May 25, 2021, 4:50:45 PM5/25/21
to IRIS, Caché, Ensemble

Michoel Reach

unread,
May 25, 2021, 4:50:57 PM5/25/21
to IRIS, Caché, Ensemble
Thanks!
Reply all
Reply to author
Forward
0 new messages