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.

<strong>Caché</strong> <strong>ObjectScript</strong> Special Variables07/23/2004T16:23:54-04:00The last part of this string (-04:00) indicates the local time variation in hours and minutesfrom Greenwich Mean Time. Note that this variation is not necessarily the time zone time.In the above case, the time zone is 5 hours west of Greenwich (-5:00), but the local timevariant (Daylight Savings Time) offsets the time zone time by one hour.ExamplesThe following example returns your current time zone:SET zone=$ZTIMEZONEIF zone=0 {WRITE !,"Your time zone is Greenwich Mean Time" }ELSEIF zone>0 {WRITE !,"Your time zone is ",zone/60," hours west of Greenwich" }ELSE {WRITE !,"Your time zone is ",(-zone)/60," hours east of Greenwich" }The following example shows that setting the time zone can change the date as well as thetime:SET zonesave=$ZTIMEZONEWRITE !,"Date in my current time zone: ",$ZDATE($HOROLOG)IF $ZTIMEZONE=0 {SET $ZTIMEZONE=720 }ELSEIF $ZTIMEZONE>0 {SET $ZTIMEZONE=($ZTIMEZONE-720) }ELSE {SET $ZTIMEZONE=($ZTIMEZONE+720) }WRITE !,"Date halfway around the world: ",$ZDATE($HOROLOG)WRITE !,"Date at Greenwich Observatory: ",$ZDATE($ZTIMESTAMP)SET $ZTIMEZONE=zonesaveThe following example determines if your local time is the same as your time zone time:SET localnow=$HOROLOG, stamp=$ZTIMESTAMPWRITE !,"local date and time: ",$ZDATETIME(localnow,1,1)SET clocksecs=$PIECE(localnow,",",2)SET stampsecs=$EXTRACT(stamp,7,11)-($ZTIMEZONE*60)IF clocksecs=stampsecs {WRITE !,"No local time variant:"WRITE !,"Local time is timezone time" }ELSE {IF clocksecs=stampsecs+3600 {WRITE !,"Daylight Savings Time variant:"WRITE !,"Local time offset 1 hour from timezone time" }ELSE { WRITE !,"Local time and time zone time are "WRITE !,(clocksecs-stampsecs)/60," minutes different" }}QUITSee Also• $ZUTIL(188) Local Time with Fractional Seconds function494 <strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong>

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

Saved successfully!

Ooh no, something went wrong!