OpenWGA 7.7 - TMLScript reference
WGAMethod :
modifyDate(date, unit, amount)
On object | WGA |
Usage | Modifies a date by adding/substracting a certain timespan |
Description |
This is a utility method for simple modifications to dates without the use of WGA.createCalendar(). it returns a new date object which represents the date of the parameter "date" plus/minus a given timespan. In order to add a timespan one is first to choose which time unit to use via argument "unit" and then the amount of units to add via argument "amount". In order to substract a timespan from the date a negative amount value is to be used. The unit is determined by the date string character that would be used by WGA.format() or WGA.parseDate() to display the time unit. |
Parameters |
date (Date): Date to modify unit (String): Character determining the date unit to add: "d" or "D" - Day amount (Number): Amount of date units to add to the date. Negative amounts effectively substract the unit. |
Return value | The modified Date |
Allowed in script types |
|
Examples |
Adding 2 weeks to a date: WGA.modifyDate(date, "w", 2); Substracting 6 months from a date: WGA.modifyDate(date, "M", -6); |