diff --git a/ts3.1-typing-tests/moment-tests.ts b/ts3.1-typing-tests/moment-tests.ts index 9ee1b2ed61..201b68dc9b 100644 --- a/ts3.1-typing-tests/moment-tests.ts +++ b/ts3.1-typing-tests/moment-tests.ts @@ -294,6 +294,19 @@ adur.subtract(bdur).days(); adur.subtract(1).days(); adur.subtract(1, 'd').days(); +var calendarFormat = { + sameDay: '[Today]', + nextDay: '[Tomorrow]', + nextWeek: 'dddd', + lastDay: '[Yesterday]', + lastWeek: '[Last] dddd', + sameElse: 'DD/MM/YYYY' +}; +moment().calendar(); +moment().calendar(null); +moment().calendar(calendarFormat); +moment().calendar(null, calendarFormat); + // Selecting a language moment.locale(); moment.locale('en'); @@ -329,6 +342,7 @@ moment.locale('en', { hh: "%d hours", d: "a day", dd: "%d days", + w: "%d weeks", M: "a month", MM: "%d months", y: "a year", diff --git a/ts3.1-typings/moment.d.ts b/ts3.1-typings/moment.d.ts index e4f531979f..3f6bb8ed60 100644 --- a/ts3.1-typings/moment.d.ts +++ b/ts3.1-typings/moment.d.ts @@ -2,7 +2,7 @@ declare function moment(inp?: moment.MomentInput, format?: moment.MomentFormatSp declare function moment(inp?: moment.MomentInput, format?: moment.MomentFormatSpecification, language?: string, strict?: boolean): moment.Moment; declare namespace moment { - type RelativeTimeKey = 's' | 'ss' | 'm' | 'mm' | 'h' | 'hh' | 'd' | 'dd' | 'M' | 'MM' | 'y' | 'yy'; + type RelativeTimeKey = 's' | 'ss' | 'm' | 'mm' | 'h' | 'hh' | 'd' | 'dd' | 'w' | 'M' | 'MM' | 'y' | 'yy'; type CalendarKey = 'sameDay' | 'nextDay' | 'lastDay' | 'nextWeek' | 'lastWeek' | 'sameElse' | string; type LongDateFormatKey = 'LTS' | 'LT' | 'L' | 'LL' | 'LLL' | 'LLLL' | 'lts' | 'lt' | 'l' | 'll' | 'lll' | 'llll'; @@ -89,6 +89,7 @@ declare namespace moment { hh?: RelativeTimeSpecVal; d?: RelativeTimeSpecVal; dd?: RelativeTimeSpecVal; + w?: RelativeTimeSpecVal; M?: RelativeTimeSpecVal; MM?: RelativeTimeSpecVal; y?: RelativeTimeSpecVal; @@ -441,6 +442,8 @@ declare namespace moment { */ subtract(unit: unitOfTime.DurationConstructor, amount: number|string): Moment; + calendar(): string; + calendar(formats: CalendarSpec): string; calendar(time?: MomentInput, formats?: CalendarSpec): string; clone(): Moment; diff --git a/typing-tests/moment-tests.ts b/typing-tests/moment-tests.ts index e3e98286f7..929f7cc732 100644 --- a/typing-tests/moment-tests.ts +++ b/typing-tests/moment-tests.ts @@ -298,6 +298,26 @@ adur.subtract(bdur).days(); adur.subtract(1).days(); adur.subtract(1, 'd').days(); +var calendarFormat = { + sameDay: '[Today]', + nextDay: '[Tomorrow]', + nextWeek: 'dddd', + lastDay: '[Yesterday]', + lastWeek: '[Last] dddd', + sameElse: 'DD/MM/YYYY' +}; +moment().calendar(); +moment().calendar(null); +moment().calendar(calendarFormat); +moment().calendar(null, { + sameDay: '[Today]', + nextDay: '[Tomorrow]', + nextWeek: 'dddd', + lastDay: '[Yesterday]', + lastWeek: '[Last] dddd', + sameElse: 'DD/MM/YYYY' +}); + // Selecting a language moment.locale(); moment.locale('en'); @@ -334,6 +354,7 @@ moment.locale('en', { hh: "%d hours", d: "a day", dd: "%d days", + w: "%d weeks", M: "a month", MM: "%d months", y: "a year",