Re: UNIX time /POSIX
Posted: Sat Oct 29, 2022 6:58 pm
Estoy apenas entrando en el mundo Harbour y FiveWin, por motivos de modificar el software que la empresa tiene. Y en otras partes uso UNIXTIME por lo que me toco realizar este código ya que no conseguí en linea otra forma:
Code: Select all | Expand
Function getUnix2(dDate,tTime)
Local nYearI := hb_ctot("1970/01/01 00:00:00.000","YYYYMMDDHHMMSSFFF")
Local cDateT := DTOC(dDate)+ " " +tTime
Local nYear := hb_ctot(cDateT)
Local nSeconds:= (nYear-nYearI) * 86400
return nSeconds
Function getUnix()
Local nYearI := hb_ctot("1970/01/01 00:00:00.000","YYYYMMDDHHMMSSFFF")
Local nYear := HB_dateTime()
Local nSeconds:= 0
nSeconds := (nYear-nYearI) * 86400
return nSeconds
Function getDateTime(nSeconds)
Local nYearI := hb_ctot("1970/01/01 00:00:00.000","YYYYMMDDHHMMSSFFF")
Local nSec := HB_dateTime()
IF VALTYPE(nSeconds)!='N'
? "Function getDateAndTime requiere como parametro una variable Numerica"
Return 0
ENDIF
nSec := nYearI + (nSeconds / 86400)
Return nSec
Function getDate(nSeconds)
Local nYearI := hb_ctot("1970/01/01 00:00:00.000","YYYYMMDDHHMMSSFFF")
Local nSec := HB_dateTime()
IF VALTYPE(nSeconds)!='N'
? "Function getDateAndTime requiere como parametro una variable Numerica"
Return 0
ENDIF
nSec := nYearI + (nSeconds / 86400)
dTemp := hb_DateTime()
dTemp := getDateTime(IIF(VALTYPE(nSeconds)=='C',VAL(nSeconds),nSeconds))
dTemp := HB_TTOC(dTemp)
cTime := SUBSTR(dTemp,12,8)
Return SUBSTR(dTemp,1,10)
Function getTime(nSeconds)
Local nYearI := hb_ctot("1970/01/01 00:00:00.000","YYYYMMDDHHMMSSFFF")
Local nSec := HB_dateTime()
IF VALTYPE(nSeconds)!='N'
? "Function getDateAndTime requiere como parametro una variable Numerica"
Return 0
ENDIF
nSec := nYearI + (nSeconds / 86400)
dTemp := hb_DateTime()
dTemp := getDateTime(IIF(VALTYPE(nSeconds)=='C',VAL(nSeconds),nSeconds))
dTemp := HB_TTOC(dTemp)
cTime := SUBSTR(dTemp,12,8)
Return SUBSTR(dTemp,12,8)