Define types for subtract method and add tests for it (#20617)

This commit is contained in:
Sergii Paryzhskyi 2017-10-17 18:07:04 +02:00 committed by Andy
parent 9266e419ed
commit bc2da03e91
2 changed files with 14 additions and 1 deletions

View File

@ -9,3 +9,13 @@ dateArithmetic.add(new Date(2010, 7, 23), 2, 'month');
dateArithmetic.add(new Date(2010, 7, 23), 2, 'year');
dateArithmetic.add(new Date(2010, 7, 23), 2, 'decade');
dateArithmetic.add(new Date(2010, 7, 23), 2, 'century');
dateArithmetic.subtract(new Date(2010, 7, 30), 1, 'second');
dateArithmetic.subtract(new Date(2010, 7, 29), 2, 'minutes');
dateArithmetic.subtract(new Date(2010, 7, 28), 3, 'hours');
dateArithmetic.subtract(new Date(2010, 7, 27), 4, 'day');
dateArithmetic.subtract(new Date(2010, 7, 26), 5, 'week');
dateArithmetic.subtract(new Date(2010, 7, 24), 6, 'month');
dateArithmetic.subtract(new Date(2010, 7, 23), 7, 'year');
dateArithmetic.subtract(new Date(2010, 7, 22), 8, 'decade');
dateArithmetic.subtract(new Date(2010, 7, 21), 9, 'century');

View File

@ -7,8 +7,11 @@ type Unit = 'second' | 'minutes' | 'hours' | 'day' | 'week' | 'month' | 'year' |
/** dateArithmetic Public Instance Methods */
interface dateArithmeticStatic {
/** Add specified amount of units to a provided date and return new date as a result */
/** Add specified amount of units to a provided date and return new date as a result */
add(date: Date, num: number, unit: Unit): Date;
/** Subtract specified amount of units from a provided date and return new date as a result */
subtract(date: Date, num: number, unit: Unit): Date;
}
declare module 'dateArithmetic' {