mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-20 12:00:53 +08:00
Update moment-node.d.ts
Add the new toObject() from the new version 2.10.5 .
This commit is contained in:
Vendored
+68
-52
@@ -1,10 +1,22 @@
|
||||
// Type definitions for Moment.js 2.8.0
|
||||
// Type definitions for Moment.js 2.10.5
|
||||
// Project: https://github.com/timrwood/moment
|
||||
// Definitions by: Michael Lakerveld <https://github.com/Lakerfield>, Aaron King <https://github.com/kingdango>, Hiroki Horiuchi <https://github.com/horiuchi>, Dick van den Brink <https://github.com/DickvdBrink>, Adi Dahiya <https://github.com/adidahiya>, Matt Brooks <https://github.com/EnableSoftware>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module moment {
|
||||
|
||||
interface MomentDateObject {
|
||||
years?: number;
|
||||
/* One digit */
|
||||
months?: number;
|
||||
/* Day of the month */
|
||||
date?: number;
|
||||
hours?: number;
|
||||
minutes?: number;
|
||||
seconds?: number;
|
||||
milliseconds?: number;
|
||||
}
|
||||
|
||||
interface MomentInput {
|
||||
/** Year */
|
||||
years?: number;
|
||||
@@ -247,8 +259,8 @@ declare module moment {
|
||||
dayOfYear(): number;
|
||||
dayOfYear(d: number): Moment;
|
||||
|
||||
from(f: Moment|string|number|Date|number[], suffix?: boolean): string;
|
||||
to(f: Moment|string|number|Date|number[], suffix?: boolean): string;
|
||||
from(f: Moment | string | number | Date | number[], suffix?: boolean): string;
|
||||
to(f: Moment | string | number | Date | number[], suffix?: boolean): string;
|
||||
toNow(withoutPrefix?: boolean): string;
|
||||
|
||||
diff(b: Moment): number;
|
||||
@@ -272,13 +284,13 @@ declare module moment {
|
||||
isDST(): boolean;
|
||||
|
||||
isBefore(): boolean;
|
||||
isBefore(b: Moment|string|number|Date|number[], granularity?: string): boolean;
|
||||
isBefore(b: Moment | string | number | Date | number[], granularity?: string): boolean;
|
||||
|
||||
isAfter(): boolean;
|
||||
isAfter(b: Moment|string|number|Date|number[], granularity?: string): boolean;
|
||||
isAfter(b: Moment | string | number | Date | number[], granularity?: string): boolean;
|
||||
|
||||
isSame(b: Moment|string|number|Date|number[], granularity?: string): boolean;
|
||||
isBetween(a: Moment|string|number|Date|number[], b: Moment|string|number|Date|number[], granularity?: string): boolean;
|
||||
isSame(b: Moment | string | number | Date | number[], granularity?: string): boolean;
|
||||
isBetween(a: Moment | string | number | Date | number[], b: Moment | string | number | Date | number[], granularity?: string): boolean;
|
||||
|
||||
// Deprecated as of 2.8.0.
|
||||
lang(language: string): Moment;
|
||||
@@ -294,43 +306,47 @@ declare module moment {
|
||||
localeData(): MomentLanguage;
|
||||
|
||||
// Deprecated as of 2.7.0.
|
||||
max(date: Moment|string|number|Date|any[]): Moment;
|
||||
max(date: Moment | string | number | Date | any[]): Moment;
|
||||
max(date: string, format: string): Moment;
|
||||
|
||||
// Deprecated as of 2.7.0.
|
||||
min(date: Moment|string|number|Date|any[]): Moment;
|
||||
min(date: Moment | string | number | Date | any[]): Moment;
|
||||
min(date: string, format: string): Moment;
|
||||
|
||||
get(unit: string): number;
|
||||
set(unit: string, value: number): Moment;
|
||||
set(objectLiteral: MomentInput): Moment;
|
||||
|
||||
/*This returns an object containing year, month, day-of-month, hour, minute, seconds, milliseconds.*/
|
||||
//Works with version 2.10.5+
|
||||
toObject(): MomentDateObject;
|
||||
}
|
||||
|
||||
type formatFunction = () => string;
|
||||
|
||||
interface MomentCalendar {
|
||||
lastDay?: string | formatFunction;
|
||||
sameDay?: string | formatFunction;
|
||||
nextDay?: string | formatFunction;
|
||||
lastWeek?: string | formatFunction;
|
||||
nextWeek?: string | formatFunction;
|
||||
sameElse?: string | formatFunction;
|
||||
lastDay?: string | formatFunction;
|
||||
sameDay?: string | formatFunction;
|
||||
nextDay?: string | formatFunction;
|
||||
lastWeek?: string | formatFunction;
|
||||
nextWeek?: string | formatFunction;
|
||||
sameElse?: string | formatFunction;
|
||||
}
|
||||
|
||||
interface BaseMomentLanguage {
|
||||
months ?: any;
|
||||
monthsShort ?: any;
|
||||
weekdays ?: any;
|
||||
weekdaysShort ?: any;
|
||||
weekdaysMin ?: any;
|
||||
relativeTime ?: MomentRelativeTime;
|
||||
meridiem ?: (hour: number, minute: number, isLowercase: boolean) => string;
|
||||
calendar ?: MomentCalendar;
|
||||
ordinal ?: (num: number) => string;
|
||||
months?: any;
|
||||
monthsShort?: any;
|
||||
weekdays?: any;
|
||||
weekdaysShort?: any;
|
||||
weekdaysMin?: any;
|
||||
relativeTime?: MomentRelativeTime;
|
||||
meridiem?: (hour: number, minute: number, isLowercase: boolean) => string;
|
||||
calendar?: MomentCalendar;
|
||||
ordinal?: (num: number) => string;
|
||||
}
|
||||
|
||||
interface MomentLanguage extends BaseMomentLanguage {
|
||||
longDateFormat?: MomentLongDateFormat;
|
||||
longDateFormat?: MomentLongDateFormat;
|
||||
}
|
||||
|
||||
interface MomentLanguageData extends BaseMomentLanguage {
|
||||
@@ -341,34 +357,34 @@ declare module moment {
|
||||
}
|
||||
|
||||
interface MomentLongDateFormat {
|
||||
L: string;
|
||||
LL: string;
|
||||
LLL: string;
|
||||
LLLL: string;
|
||||
LT: string;
|
||||
LTS: string;
|
||||
l?: string;
|
||||
ll?: string;
|
||||
lll?: string;
|
||||
llll?: string;
|
||||
lt?: string;
|
||||
lts?: string;
|
||||
L: string;
|
||||
LL: string;
|
||||
LLL: string;
|
||||
LLLL: string;
|
||||
LT: string;
|
||||
LTS: string;
|
||||
l?: string;
|
||||
ll?: string;
|
||||
lll?: string;
|
||||
llll?: string;
|
||||
lt?: string;
|
||||
lts?: string;
|
||||
}
|
||||
|
||||
interface MomentRelativeTime {
|
||||
future: any;
|
||||
past: any;
|
||||
s: any;
|
||||
m: any;
|
||||
mm: any;
|
||||
h: any;
|
||||
hh: any;
|
||||
d: any;
|
||||
dd: any;
|
||||
M: any;
|
||||
MM: any;
|
||||
y: any;
|
||||
yy: any;
|
||||
future: any;
|
||||
past: any;
|
||||
s: any;
|
||||
m: any;
|
||||
mm: any;
|
||||
h: any;
|
||||
hh: any;
|
||||
d: any;
|
||||
dd: any;
|
||||
M: any;
|
||||
MM: any;
|
||||
y: any;
|
||||
yy: any;
|
||||
}
|
||||
|
||||
interface MomentStatic {
|
||||
@@ -460,8 +476,8 @@ declare module moment {
|
||||
max(...moments: Moment[]): Moment;
|
||||
|
||||
normalizeUnits(unit: string): string;
|
||||
relativeTimeThreshold(threshold: string): number|boolean;
|
||||
relativeTimeThreshold(threshold: string, limit:number): boolean;
|
||||
relativeTimeThreshold(threshold: string): number | boolean;
|
||||
relativeTimeThreshold(threshold: string, limit: number): boolean;
|
||||
|
||||
/**
|
||||
* Constant used to enable explicit ISO_8601 format parsing.
|
||||
|
||||
Reference in New Issue
Block a user