Expand/Shrink

adjust_timedate

Definition: include builtins\timedate.e

timedate td = adjust_timedate(timedate td, atom delta)
Description: returns a timedate adjusted by the specified delta in seconds.
pwa/p2js: Supported.
Comments: The delta parameter is normally the result of a call to timedelta().

If the timedate has a timezone with a daylight savings rule, it automatically toggles on or off as the date crosses the start and end dates, with the appropriate (additional) time shift.

While the day of year is automatically recalculated, note however this routine assumes that td[DT_DOW] is actually td[DT_MSEC] and applies any fraction of a second in delta accordingly. As per the example below, while format_timedate() does not actually use or believe the content of td[DT_DOW], you might need that commented out line, or similar, if you are using it directly.
Example:
include builtins\timedate.e
timedate td = parse_date_string("1/1/2015",{"D/M/YYYY"})
?format_timedate(td,"Dddd, Mmmm dst, yyyy")
-- displays "Thursday, January 1st, 2015"
td = adjust_timedate(td,timedelta(days:=4))
--td[DT_DOW] = day_of_week(td[DT_YEAR],td[DT_MONTH],td[DT_DAY])
?format_timedate(td,"Dddd, Mmmm dst, yyyy")
-- displays "Monday, January 5th, 2015"
See Also: timedate, the timedate type, timedelta, parse_date_string, format_timedate