if you need epochtime
Posted: Tue Aug 01, 2023 11:35 pm
Hi guys
If you need to get epoch time in your programs, epoch time, "unix time", basically the number of seconds since Unix was created "midnight 1/1/1970", there are different ways, one way is to use a formula in your program and get it from #datetimex.now, but you have to be careful with GMT and stuff.
Easiest way if you are running in the web, is to ask for it to javascript (one of unix sons). For that you can create a simple widget (lets say JSTools), make it a Widget Type Object, add a propertiy like EpochTime, to return a Decimal:
then you can copy those lines in the sample implementation, to the implementation tab, and replace all if you wish with this lines:
Compile it.
Then in your web page, view, dialog, reusable part of type web, you can drag and drop the widget to it and use it as needed:
If you need to get epoch time in your programs, epoch time, "unix time", basically the number of seconds since Unix was created "midnight 1/1/1970", there are different ways, one way is to use a formula in your program and get it from #datetimex.now, but you have to be careful with GMT and stuff.
Easiest way if you are running in the web, is to ask for it to javascript (one of unix sons). For that you can create a simple widget (lets say JSTools), make it a Widget Type Object, add a propertiy like EpochTime, to return a Decimal:
then you can copy those lines in the sample implementation, to the implementation tab, and replace all if you wish with this lines:
Code: Select all
function( PROTOTYPE, WIDGET )
{
PROTOTYPE.onCreateInstance = function() { }
// EpochTime - Gets Epoch Time
// Type: Decimal
PROTOTYPE.getEpochTime = function() { return new Date().getTime(); }
PROTOTYPE.setEpochTime = function( decValue ) { this.m_EpochTime = decValue; }
// Even though EpochTime is read-only, setEpochTime is still required for the default value
return WIDGET.Completed;
}
Then in your web page, view, dialog, reusable part of type web, you can drag and drop the widget to it and use it as needed:
Code: Select all
Begin_Com Role(*EXTENDS #PRIM_WEB) Theme(#SYS_THEME<MaterialDesignBlue>)
Define_Com Class(#JSTools) Name(#JSTools)
Define_Com Class(#PRIM_MD.Label) Name(#Text) Caption('Epoch Time') DisplayPosition(1) Height(45) Left(20) Parent(#COM_OWNER) TabPosition(1) ThemeDrawStyle('Title') Top(24) Width(405) Hint('Epoch Time')
Evtroutine Handling(#Com_owner.Initialize)
#Text.Caption := #JSTools.EpochTime.AsString
Endroutine
End_Com