From 8ad485ea27d90db0458024c1da26f669f2e16ad0 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Fri, 20 Jun 2014 14:08:30 +0100 Subject: [PATCH] Add extra add overloads --- moment/moment-tests.ts | 7 +++++++ moment/moment.d.ts | 47 +++++++++++++++++++++++++++++++++++------- 2 files changed, 46 insertions(+), 8 deletions(-) diff --git a/moment/moment-tests.ts b/moment/moment-tests.ts index 1c8b7c82cf..d0dd0bda2b 100644 --- a/moment/moment-tests.ts +++ b/moment/moment-tests.ts @@ -78,6 +78,13 @@ m2.add('hours', 24).hours(); var duration = moment.duration({'days': 1}); moment([2012, 0, 31]).add(duration); +moment().add('seconds', 1); +moment().add('seconds', '1'); +moment().add(1, 'seconds'); + +moment().add('1', 'seconds'); +moment().add('seconds', '1'); + moment().subtract('days', 7); moment().seconds(30); diff --git a/moment/moment.d.ts b/moment/moment.d.ts index 879bf6eae8..f14c7d4beb 100644 --- a/moment/moment.d.ts +++ b/moment/moment.d.ts @@ -60,14 +60,45 @@ interface Moment { fromNow(withoutSuffix?: boolean): string; - startOf(soort: string): Moment; - endOf(soort: string): Moment; + startOf(unitOfTime: string): Moment; + endOf(unitOfTime: string): Moment; - add(input: MomentInput): Moment; - add(soort: string, aantal: number): Moment; + /** + * Mutates the original moment by adding time. + * + * @param unitOfTime the key of what time you want to add (eg "years" / "hours" etc) + * @param amount the amount you want to add + */ + add(unitOfTime: string, amount: number): Moment; + /** + * Mutates the original moment by adding time. + * + * @param amount the amount you want to add + * @param unitOfTime the key of what time you want to add (eg "years" / "hours" etc) + */ + add(amount: number, unitOfTime: string): Moment; + /** + * Mutates the original moment by adding time. + * + * @param unitOfTime the key of what time you want to add (eg "years" / "hours" etc) + * @param amount the amount you want to add + */ + add(unitOfTime: string, amount: string): Moment; + /** + * Mutates the original moment by adding time. + * + * @param objectLiteral an object literal that describes multiple different keys at the same time {days:7,months:1} + */ + add(objectLiteral: MomentInput): Moment; + /** + * Mutates the original moment by adding time. + * + * @param duration a length of time + */ add(duration: Duration): Moment; + subtract(input: MomentInput): Moment; - subtract(soort: string, aantal: number): Moment; + subtract(unitOfTime: string, amount: number): Moment; calendar(): string; clone(): Moment; @@ -123,8 +154,8 @@ interface Moment { from(date: number[]): string; diff(b: Moment): number; - diff(b: Moment, soort: string): number; - diff(b: Moment, soort: string, round: boolean): number; + diff(b: Moment, unitOfTime: string): number; + diff(b: Moment, unitOfTime: string, round: boolean): number; toDate(): Date; toISOString(): string; @@ -291,7 +322,7 @@ interface MomentStatic { ordinal: (num: number) => string; duration(milliseconds: Number): Duration; - duration(num: Number, soort: string): Duration; + duration(num: Number, unitOfTime: string): Duration; duration(input: MomentInput): Duration; duration(object: any): Duration; duration(): Duration;