11.07.2015 Views

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

You can obtain the same time stamp information as $ZTIMESTAMP by invoking a systemmethod, using either of the following syntax forms:WRITE !,$SYSTEM.SYS.TimeStamp()WRITE !,##class(%SYSTEM.SYS).TimeStamp()Refer to the $SYSTEM special variable and the “Class %SYSTEM.SYS” section of the<strong>Caché</strong> Class <strong>Reference</strong> for further details.ExampleThe following example converts the value of $ZTIMESTAMP to local time, and comparesit with two representations of local time: $ZUTIL(188) and $HOROLOG:SET stamp=$ZTIMESTAMP,clock=$HOROLOG,miliclock=$ZUTIL(188)WRITE !,"local date and time: ",$ZDATETIME(clock,1,1,2)WRITE !,"local date and time: ",$ZDATETIME(miliclock,1,1,2)WRITE !,"UTC date and time: ",$ZDATETIME(stamp,1,1,2)IF $PIECE(stamp,",",2) = $PIECE(clock,",",2) {WRITE !,"Local time is UTC time" }ELSEIF $PIECE(stamp,",") '= $PIECE(clock,",") {WRITE !,"Time difference affects date" }ELSE {SET localutc=$ZUTIL(193,stamp)WRITE !,"Converted local date and time: ",$ZDATETIME(localutc,1,1,2)}QUITThe following example compares the values returned by $ZTIMESTAMP and $HOROLOG,and shows how the time portion of $ZTIMESTAMP may be converted. (Note that in thissimple example only one adjustment is made for local time variations, such as DaylightSavings Time. Other types of local variation may cause clocksecs and stampsecs to containirreconcilable values.)SET stamp=$ZTIMESTAMP,clock=$HOROLOGWRITE !,"local date and time: ",$ZDATETIME(clock,1,1,2)WRITE !,"UTC date and time: ",$ZDATETIME(stamp,1,1,2)IF $PIECE(stamp,",") '= $PIECE(clock,",") {WRITE !,"Time difference affects date" }SET clocksecs=$EXTRACT(clock,7,11)SET stampsecs=$EXTRACT(stamp,7,11)-($ZTIMEZONE*60)IF clocksecs=stampsecs {WRITE !,"No local time variant"WRITE !,"Local time is timezone time" }ELSE {SET stampsecs=stampsecs+3600IF clocksecs=stampsecs {WRITE !,"Daylight Savings Time variant:"WRITE !,"Local time offset 1 hour from timezone time" }ELSE { WRITE !,"Cannot reconcile due to local time variant" }}QUIT$ZTIMESTAMP<strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong> 491

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!