Expand/Shrink

timedelta

Definition: include builtins\timedate.e

atom delta = timedelta(atom weeks=0, days=0, hours=0, minutes=0, seconds=0, milliseconds=0, microseconds=0)
Description: Returns a duration of time expressed in seconds and fractions of a second (idea cribbed from python)
pwa/p2js: Supported.
Comments: The result is intended to be used as a parameter to adjust_timedate().

The parameters are expected to be named: while 7 hours and 30 minutes could legally be defined using timedelta(0,0,7,30[,0,0,0]), it is recommended that the far more readable timedelta(hours:=7, minutes:=30) or timedelta(hours:=7.5) be used instead.

Fairly obviously, -7000 hours is just as valid as +7000 hours, as is +10 weeks -3 days (together), in other words there is no and cannot be any validation of "sensible" ranges or matching "signedness" of any parameters, except perhaps for atoms that are not and do not turn into inf or nan, but even that’s not attempted or tested.
Example:
include builtins\timedate.e
atom fourdays = timedelta(days:=4)
timedate td = parse_date_string("1/8/2016",{"D/M/YYYY"})
?format_timedate(td,"Dddd, Mmmm dth, yyyy")                 -- displays "Monday, August 1st, 2016"
td = adjust_timedate(td,fourdays)
?format_timedate(td,"Dddd, Mmmm dth, yyyy")                 -- displays "Friday, August 5th, 2016"
td = adjust_timedate(td,-fourdays)
?format_timedate(td,"Dddd, Mmmm dth, yyyy")                 -- displays "Monday, August 1st, 2016"
See Also: timedate, adjust_timedate, parse_date_string, format_timedate, elapsed
Expand/Shrink