Object
,number
,string
Object
Adds the given amount of time to a provided date object. Day, week, month, and year increments maintain the same hour for changes that pass through daylight saving time.
Object
The date object
number
The amount of time to add (or subtract if negative)
string
(optional) The time unit to use. Defaults to milliseconds
Object
An updated date object
dateAdd() should return a date in the future when current date is passed with a positive increment | Pass |
dateAdd() should return a date in the past when current date is passed with a negative increment | Pass |
dateAdd() should return an identical date when the increment is 0 | Pass |
dateAdd() should default to milliseconds when no time unit is specified | Pass |
dateAdd() should default to milliseconds when an unsupported time unit is specified | Pass |
dateAdd() should retain the time but increment the date when passing through daylight saving time for units of days and above | Pass |
dateAdd() should return undefined when the first argument is not a Date object | Pass |
dateAdd() should properly handle leap years when incrementing Feb 29th date to non leap year | Pass |
dateAdd() should properly handle leap years when incrementing Feb 29th date to other leap year | Pass |
dateAdd() should revert to last day of month when incrementing to month that doesn’t contain current day | Pass |