Código: Selecionar todos
import datetime
today = datetime.date.today()
three_days_ago = today - datetime.timedelta(days=3)
print("Today:", today)
print("Three days ago:", three_days_ago)
Não encontrei muitas informações sobre uma função desse nível em harbour, obviamente encontrei algo sobre datas em harbour bem como todas a suas funções:
Código: Selecionar todos
CDoW() Converts a date to the day of week
CMonth() Return the name of the month.
CToD() Converts a character string to a date expression
Date() Return the Current OS Date
Day() Return the numeric day of the month.
Days() Convert elapsed seconds into days
DoW() Value for the day of week.
DToC() Date to character conversion
DToS() Date to string conversion
ElapTime() Calculates elapsed time.
hb_DToT() Create a tDateTime value from a dDate parameter
hb_Week() Returns the week number of year.
Month() Converts a date expression to a month value
Seconds() Returns the number of elapsed seconds past midnight.
Secs() Return the number of seconds from the system date.
Time() Returns the system time as a string
Year() Extracts the year designator of a given date as a numeric value
Sendo assim me atrevi a criar uma função básica aqui que por incrível que possa parecer funciona.
Código: Selecionar todos
FUNCTION TimeDelta( days, hours, minutes, seconds )
IF days > 0
days := ((days * 24) * 60 ) / (24 * 60)
ENDIF
IF hours > 0
hours := (hours * 60 ) / (24 * 60)
ENDIF
IF minutes > 0
minutes := minutes / (24 * 60)
ENDIF
IF seconds > 0
seconds := (seconds / 60) / (24 * 60)
ENDIF
RETURN days + hours + minutes + seconds
Código: Selecionar todos
dtNow := hb_DateTime()
dtNewDateHour := dtNow + TimeDelta(5, 3, 35, 45)
? "Data e Hora Atual:", dtNow
? "Nova Data e Hora:", dtNewDateHour
Código: Selecionar todos
dtNow := hb_DateTime()
dtNewDateHour := dtNow - TimeDelta(0, 0, 0, 45)
? "Data e Hora Atual:", dtNow
? "Nova Data e Hora:", dtNewDateHour
Código: Selecionar todos
dtNow := hb_DateTime()
dtNewDateHour := dtNow + TimeDelta(0, 1, 0, 0)
? "Data e Hora Atual:", dtNow
? "Nova Data e Hora:", dtNewDateHour
Código: Selecionar todos
dtNow := hb_DateTime()
dtNewDateHour := dtNow - TimeDelta(0, 1, 0, 0)
? "Data e Hora Atual:", dtNow
? "Nova Data e Hora:", dtNewDateHour

