June 14, 2006, 05:11 AM
Tony AHi Prarie,
When you say non-military, do you mean taking the time zone of the machine? If so there is an article by John Gray that uses reg.exe in a windows based system
here in the Focus on Developers pages. This article also references the
Zulu Time article by Susannah and both make excellent reading.
I have taken John's suggestion and produced a fex that you can include to obtain an offset -
-* system call to write the registry value to a file
! REG QUERY HKLM\SYSTEM\CURRENTCONTROLSET\CONTROL\TIMEZONEINFORMATION /V ACTIVETIMEBIAS > TZ.TXT
-*(above must be on one line)
-* filedef the file generated so that it can be read using a -READ
APP FI TZ DISK TZ.MAS
-RUN
-WRITE TZ
-WRITE TZ FILE=TZ,SUFFIX=FIX
-WRITE TZ SEGNAME=SEG1
-WRITE TZ FIELD=DATA_KEY,,A80,A80,$
-WRITE TZ DEFINE HEX/A10 = RJUST(10,GETTOK(DATA_KEY, 128, -1, 'x', 10, 'A10'),'A10');
-WRITE TZ DEFINE HEX1A/A3 = EDIT(HEX,'$$$$$$$9$$');
-WRITE TZ DEFINE HEX2A/A3 = EDIT(HEX,'$$$$$$$$9$');
-WRITE TZ DEFINE HEX3A/A3 = EDIT(HEX,'$$$$$$$$$9');
-WRITE TZ DEFINE HEX1/I3 = IF HEX1A EQ ' ' THEN 0 ELSE IF HEX1A FROM '0' TO '9' THEN BYTVAL(HEX1A, 'I3') - 48 ELSE BYTVAL(HEX1A, 'I3') - 87 ;
-WRITE TZ DEFINE HEX2/I3 = IF HEX2A EQ ' ' THEN 0 ELSE IF HEX2A FROM '0' TO '9' THEN BYTVAL(HEX2A, 'I3') - 48 ELSE BYTVAL(HEX2A, 'I3') - 87 ;
-WRITE TZ DEFINE HEX3/I3 = IF HEX3A EQ ' ' THEN 0 ELSE IF HEX3A FROM '0' TO '9' THEN BYTVAL(HEX3A, 'I3') - 48 ELSE BYTVAL(HEX3A, 'I3') - 87 ;
-RUN
FILEDEF TZ DISK ./TZ.TXT (LRECL 80 RECFM V
-RUN
TABLE FILE TZ
PRINT COMPUTE MyOffset/D5 = ( -4096 * (HEX CONTAINS 'fffff')) + ((HEX1 * 256) + (HEX2 * 16) + HEX3);
WHERE DATA_KEY CONTAINS 'ACTIVETIMEBIAS'
ON TABLE SAVE AS HEXVALUE
END
-RUN
-* read the saved data that contains the required value
-READ HEXVALUE &Offset.A5.
-RUN
and used it in another fex using Susannah's suggestion within a reuseable function -
-SET &Time = EDIT(&TOD,'99$99');
-INCLUDE TimeZone
-SET &OFFSETHOURS =-(&Offset/60);
DEFINE FUNCTION ZULUTIME(OFFSET/A10, VALUE/D4)
NOWDATETIME_A/HYYMDS=HGETC(8, 'HYYMDS');
NOWDATETIME/HYYMDS=HADD(NOWDATETIME_A, OFFSET, VALUE, 8, 'HYYMDS');
DAYSDIFF/D8=DATEDIF('19700101', '&YYMD', 'D');
MSDIFF/D32=DAYSDIFF*24*60*60*1000;
ADDOFFSET/D12=&OFFSETHOURS*60*60*1000;
NOWMILLISEC/D12 = HTIME(8, NOWDATETIME, 'D12.2');
NEEDTOADD/D13=NOWMILLISEC+ADDOFFSET+MSDIFF;
ZULUTIME/A17=FTOA(NEEDTOADD, '(D13c)', 'A17');
END
-RUN
-SET &NextRunTime='0000000000000000000' | ZULUTIME('minute',-110);
which I use to update the BOTSCHED file as necessary.
Hope this helps.
T
p.s. I know this is a wide posting but I have left it like this purposefully so that the -write lines are not split.
June 23, 2006, 09:22 AM
FocWizardBased on my reading of the request, it would seem Prairie wants a value like:
YYYY/MM/DD HH:MM:SSAP
where YYYY is the year; MM is the month; DD is the day; HH is the hour; MM is the minute; SS is the second; and AP is 'AM' or 'PM'.
Assuming that is what's wanted, you can use a DEFINE with the appropriate format. If you don't reference any database fields, it is only evaluated ONCE. You can see this with a '? DEFINE', which shows that the define is NOT associated with any segment (it's global).
If you want it via Dialogue Manager, you can also get it. The first thing you need to understand, is that EVERY field stored as a Dialogue Manager value, is stored as a character string. That's why you have to work to get decimals from a calculation, as we don't know HOW MANY decimal places to keep.
So, with that said, here's how I did it:
-SET &NOW = HCNVRT(HGETC(8,'HYYMDm'),'(HYYMDSA)',30,'A30');
This is actually a subroutine call as an argument to another subroutine call. The HGETC retrieved the current date-time, as a DATE-TIME formatted field. We provide that as the FIRST argument to the HCNVRT routine, which converts a date-time field to an alpha (required by D.M. remember?).
The current time is retrieved to milliseconds, then converted to a display format with the time indicated by an AM or PM.
Hope that's what you were looking for.
June 23, 2006, 10:13 AM
susannahsweet!
and loaded with ancillary info.
June 23, 2006, 10:22 AM
<RickW>Here's the DEFINE for time - although the DM version is more flexible.
DEFINE FILE CAR
CURRTIME/HHISA= HGETC(8,'HHISA');
END
TABLE FILE CAR
" <CURRTIME "
PRINT CAR
END
June 23, 2006, 04:01 PM
PrarieThanks to everyone...
Focwizard...
-SET &NOW = HCNVRT(HGETC(8,'HYYMDm'),'(HYYMDSA)',30,'A30');
That's it!!