Hello!
Is there a function in Express, or in XBase++ that returns date, time, and time zone in GMT format?
example:
2023-05-05T22:00:27.9545853-04:00
I will appreciate the help.
GMT Format
-
- Posts: 176
- Joined: Thu Nov 05, 2020 10:51 am
- Location: DOMINICAN REPUBLIC
Re: GMT Format
In postgress
you can use select LOCALTIMESTAMP and it will return "2023-06-16 14:08:15.606786"
you can use select LOCALTIMESTAMP and it will return "2023-06-16 14:08:15.606786"
Nolberto Paulino
Regards
Regards
Re: GMT Format
hi Diego
ot4xb have those Date/Time Function to use with "TimeZone"
i attach CLASS TIME_ZONE_INFORMATION which can help you
ot4xb have those Date/Time Function to use with "TimeZone"
i attach CLASS TIME_ZONE_INFORMATION which can help you
Code: Select all
#define _OT4XB_MAP_WAPIST_FUNC_
#include "ot4xb.ch"
// ---------------------------------------------------------------------------
DLL KERNEL32 IMPORT GetSystemTime AS VOID ;
PARAM pSt AS POINTER32
// ---------------------------------------------------------------------------
DLL KERNEL32 IMPORT SystemTimeToTzSpecificLocalTime AS BOOL ;
PARAM pTz AS POINTER32 ,;
PARAM pStGtm AS POINTER32 ,;
PARAM pStLocal AS POINTER32
// ---------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------
BEGIN STRUCTURE REG_TZI_FORMAT
MEMBER LONG Bias
MEMBER LONG StandardBias
MEMBER LONG DaylightBias
MEMBER @SYSTEMTIME StandardDate
MEMBER @SYSTEMTIME DaylightDate
END STRUCTURE
//----------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------
BEGIN STRUCTURE _TIME_ZONE_INFORMATION_base
MEMBER LONG Bias
MEMBER BINSTR _StandardName_ SIZE 64
MEMBER @SYSTEMTIME StandardDate
MEMBER LONG StandardBias
MEMBER BINSTR _DaylightName_ SIZE 64
MEMBER @SYSTEMTIME DaylightDate
MEMBER LONG DaylightBias
END STRUCTURE
//----------------------------------------------------------------------------------------------------------------------
CLASS TIME_ZONE_INFORMATION FROM _TIME_ZONE_INFORMATION_base
EXPORTED:
// ---------------------------------------------------------------------------------
INLINE CLASS METHOD initclass() ; return Self // required on 1st GWST subclass
// ---------------------------------------------------------------------------------
INLINE CLASS METHOD systime2str( st )
return cPrintf("Year:%04.4hu Month:%02.2hu Day:%02.2hu Hour:%02.2hu Minute:%02.2hu Second:%02.2hu",;
st:wYear,st:wMonth,st:wDay,st:wHour,st:wMinute,st:wSecond);
// ---------------------------------------------------------------------------------
INLINE METHOD ShowStandardDate() ; return ::systime2str( ::StandardDate )
INLINE METHOD ShowDaylightDate() ; return ::systime2str( ::DaylightDate )
// ---------------------------------------------------------------------------------
INLINE ACCESS ASSIGN METHOD StandardName(v)
if( PCount() > 0 )
::_StandardName_ := cSzAnsi2Wide(v)
return NIL
end
return TrimZ( cSzWide2ansi(::_StandardName_) )
// ---------------------------------------------------------------------------------
INLINE ACCESS ASSIGN METHOD DaylightName(v)
if( PCount() > 0 )
::_DaylightName_ := cSzAnsi2Wide(v)
return NIL
end
return TrimZ( cSzWide2ansi(::_DaylightName_) )
// ---------------------------------------------------------------------------------
INLINE CLASS METHOD GetKeyNames()
local aNames := Array(0)
local buffer := ChrR(0,1024)
local hk := 0
local key_name := "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones"
local index := 0
local cb := 1024
if( @advapi32:RegOpenKeyExA(HKEY_LOCAL_MACHINE,key_name,0,0x20019,@hk) == 0 )
while( @advapi32:RegEnumKeyExA(hk,index,@buffer,@cb,0,0,0,0) == 0 )
#IFDEF UseBigArray
AADD( aNames,{STRTRAN(cPrintf("%s",buffer),CHR(0),""),"","","","","",0,0})
#ELSE
AADD( aNames , cPrintf("%s",buffer) )
#ENDIF
index++
cb := 1024
end
@advapi32:RegCloseKey(hk)
end
return aNames
// ---------------------------------------------------------------------------------
INLINE CLASS METHOD FromName( name )
local tzi := NIL
local key_name := cPrintf("SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\%s",name)
local hk := 0
local rgzi,p,cb
if( @advapi32:RegOpenKeyExA(HKEY_LOCAL_MACHINE,key_name,0,0x20019,@hk) == 0 )
tzi := ::New()
tzi:_alloc_()
p := tzi:_addressof_("_StandardName_")
cb := tzi:_sizeof_("_StandardName_")
@advapi32:RegQueryValueExW(hk,cszAnsi2Wide("Std"),0,0,p,@cb)
p := tzi:_addressof_("_DaylightName_")
cb := tzi:_sizeof_("_DaylightName_")
@advapi32:RegQueryValueExW(hk,cszAnsi2Wide("Dlt"),0,0,p,@cb)
rgzi := REG_TZI_FORMAT():New()
cb := rgzi:_sizeof_()
if( @advapi32:RegQueryValueExA(hk,"TZI",0,0,rgzi,@cb) == 0 )
tzi:Bias := rgzi:Bias
tzi:StandardBias := rgzi:StandardBias
tzi:DaylightBias := rgzi:DaylightBias
@ot4xb:_bcopy( tzi:StandardDate , rgzi:StandardDate , tzi:StandardDate:_sizeof_() )
@ot4xb:_bcopy( tzi:StandardDate , rgzi:DaylightDate , tzi:DaylightDate:_sizeof_() )
end
tzi:_free_()
@advapi32:RegCloseKey(hk)
end
return tzi
// ---------------------------------------------------------------------------------
ENDCLASS
greetings by OHR
Jimmy
Jimmy
-
- Posts: 176
- Joined: Thu Nov 05, 2020 10:51 am
- Location: DOMINICAN REPUBLIC
Re: GMT Format
Hello, Nolberto, and Jimmy.
Thank you so much.
Thank you so much.