From bc2da03e918e8cd50cf9edb17b8e43c11d3880da Mon Sep 17 00:00:00 2001 From: Sergii Paryzhskyi Date: Tue, 17 Oct 2017 18:07:04 +0200 Subject: [PATCH] Define types for subtract method and add tests for it (#20617) --- types/date-arithmetic/date-arithmetic-tests.ts | 10 ++++++++++ types/date-arithmetic/index.d.ts | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/types/date-arithmetic/date-arithmetic-tests.ts b/types/date-arithmetic/date-arithmetic-tests.ts index 11e2dba3c6..509551dd92 100644 --- a/types/date-arithmetic/date-arithmetic-tests.ts +++ b/types/date-arithmetic/date-arithmetic-tests.ts @@ -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'); diff --git a/types/date-arithmetic/index.d.ts b/types/date-arithmetic/index.d.ts index 813b408730..ad669fd523 100644 --- a/types/date-arithmetic/index.d.ts +++ b/types/date-arithmetic/index.d.ts @@ -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' {