UNIX time /POSIX

UNIX time /POSIX

Postby MOISES » Fri Nov 08, 2019 7:30 pm

Hello,

Is there a function for that?

Thank you
Saludos / Regards,

FWH 20.04, Harbour 3.2.0 dev (r1909261630) y BCC 7.40
MOISES
 
Posts: 838
Joined: Wed Aug 22, 2007 10:09 am

Re: UNIX time /POSIX

Postby Baxajaun » Sat Nov 09, 2019 6:42 pm

Hi Moises,

have a look this link

https://github.com/Petewg/harbour-core/wiki/Date-Time

Thanks.

Best regards,
User avatar
Baxajaun
 
Posts: 968
Joined: Wed Oct 19, 2005 2:17 pm
Location: Gatika. Bizkaia

Re: UNIX time /POSIX

Postby MaxSaeta » 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 view

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)
 
MaxSaeta
 
Posts: 2
Joined: Wed Oct 26, 2022 9:19 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 84 guests