Focal Point
[SOLVED] BOTSIT NEXTRUNTIME convert to datetime?

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/6317046296

February 18, 2020, 10:31 AM
DWaybright
[SOLVED] BOTSIT NEXTRUNTIME convert to datetime?
I'm trying to get my head around this -- I'm not familiar with Zulu or UTC time fields, which is what I believe the NEXTRUNTIME field is, although the format of the field is A32V (according to the ?FF I ran).
How can I get this to show on a report in HMDYY format? I have just been using code, but I suppose I could convert to SQL pass-thru. I'm just trying to get a list of reports with a future NEXTRUNTIME.
Thanks!
--Deb

This message has been edited. Last edited by: DWaybright,


WebFOCUS 8.2.03 (production), 8.2.06 (testing)
AppStudio, InfoAssist
Windows, All Outputs
February 18, 2020, 01:53 PM
BabakNYC
Those numbers don't look like Zulu time.


WebFOCUS 8206, Unix, Windows
February 18, 2020, 02:53 PM
FP Mod Chuck
Deb

I found this code on techsupport, don't make me explain why it works but it does...


JOIN SCHEDULEID IN BOTSCHED TO UNIQUE SCHEDULEID IN BOTSIT
DEFINE FILE BOTSCHED
NUM_NEXTRUNTIME/D14 WITH NEXTRUNTIME = EDIT(NEXTRUNTIME) ;
START_DATE/I8YYMD WITH NEXTRUNTIME = 19700101;
SMART_START/YYMD=START_DATE;
CASTER_START/HYYMDIA = HDTTM(SMART_START, 8, 'HYYMDIA');
NEXT_RUNTIME/HYYMDIA = HADD(CASTER_START,'MILLISECONDS', NUM_NEXTRUNTIME, 8, 'HYYMDIA');
END
TABLE FILE BOTSCHED
PRINT NEXT_RUNTIME
BY SCHEDULEID
END



Thank you for using Focal Point!

Chuck Wolff - Focal Point Moderator
WebFOCUS 7x and 8x, Windows, Linux All output Formats
February 18, 2020, 03:05 PM
Hallway
It looks like it is using The ECMAScript epoch and timestamps, which is the number of milliseconds that have elapsed since midnight on January 1, 1970, UTC.

January 1, 1970, UTC is the same as the UNIX epoch, which is the predominant base value for computer-recorded date and time values.

Open the dev tools in a browser, go to the console and enter
  
new Date( [value of NEXTRUNTIME] ) 
You will see the date.

**EDIT
Unless NEXTRUNTIME = '00000000000009223372036854775807' in which case it means NEXTRUNTIME = 'never'

So, looking at Chuck's code above, it is converting the string to a number and adding that number of miliseconds to the UNIX epoch of January 1, 1970, UTC.

This message has been edited. Last edited by: Hallway,


Hallway

 
Prod: 8202M1
Test: 8202M4
Repository:
 
OS:
 
Outputs:
 
 
 
 
February 19, 2020, 09:57 AM
DWaybright
Chuck -- Thanks! That gave me what I needed.
Hallway -- Thanks for the explanation. I do appreciate knowing why something works and what I'm really looking at.

--Deb


WebFOCUS 8.2.03 (production), 8.2.06 (testing)
AppStudio, InfoAssist
Windows, All Outputs
February 19, 2020, 11:08 AM
FP Mod Chuck
Hallway

I thank you as well for the explanation, I had no idea why they picked that date to add to the field value... Learn something new everyday..


Thank you for using Focal Point!

Chuck Wolff - Focal Point Moderator
WebFOCUS 7x and 8x, Windows, Linux All output Formats
February 20, 2020, 03:26 AM
Tony A
@ Chuck,

There used to be an article that explained this (and other tips and techniques) but I can't locate any of them now.

Any idea what happened to them? If they're still accessible and where?

T
February 20, 2020, 03:30 AM
Tony A
Ummm, scratch that, just need to click on the "Community Center" link at the top of this page and then choose "Tips and Techniques" from the bottom link in the centre of the "Forum Highlights" section.
Zulu Time - How to Read the ReportCaster Schedule File


T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
February 20, 2020, 06:25 AM
Tony A
In addition to the article written by Susannah in 2003(?), You can obtain an indicator whether the current time zone is affected by daylight saving.

This is what I use -

-* Call reg.exe to obtain the current time offset due to BST
CMD REG QUERY HKLM\SYSTEM\CURRENTCONTROLSET\CONTROL\TIMEZONEINFORMATION /V ACTIVETIMEBIAS > TZ.TXT
-RUN
-* Allocate the timezone data so that we can read the values
FILEDEF TZDATA DISK TZ.TXT (LRECL 80 RECFM V
-RUN

-* Read the values from the line containing the word 'ACTIVETIMEBIAS'
-:LAB_000;
-READ TZDATA &TZDATA.A80.
-IF &TZDATA OMITS 'ACTIVETIMEBIAS' THEN GOTO :LAB_000;
-SET &HEXVAL = GETTOK(&TZDATA, 80, -1, 'x', 10, 'A10');

-* Using the returned hexadecimal value, determine the epoch time to feed into the conversion
-* of the START_STAMP which is a count of milliseconds since the epoch time.
-*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* WARNING: As the machine current time offset is used, any data that is loaded COULD be
-* an hour out.
-*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-SET &EPOCH = DECODE &HEXVAL('ffffffc4' '19700101 01:00:00' ELSE '19700101 00:00:00');
-TYPE The EPOCH time being used is &EPOCH.EVAL


and then in a define -

  EPOCH/HYYMDs          = HINPUT(&EPOCH.LENGTH, &EPOCH.QUOTEDSTRING, 8, 'HYYMDs');
  BEG_TIMESTAMP/HYYMDs 	= IF START_STAMP NE '' THEN HADD(EPOCH, 'ms', EDIT(START_STAMP), 8, BEG_TIMESTAMP) ELSE EPOCH;
  END_TIMESTAMP/HYYMDs 	= IF END_STAMP   NE '' THEN HADD(EPOCH, 'ms', EDIT(END_STAMP), 8, END_TIMESTAMP) ELSE EPOCH;


T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
February 20, 2020, 06:33 AM
Tony A
I should add the fact that I use GMT so I don't have to worry about time zones other than when we are in BST (British Summer Time).

You can derive the time zone information from the first section.

There was an article by John Gray (JG) that gave examples etc. here

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10