diff --git a/test/plugin/isBetween.d.test.ts b/test/plugin/isBetween.d.test.ts new file mode 100644 index 000000000..4542e4b61 --- /dev/null +++ b/test/plugin/isBetween.d.test.ts @@ -0,0 +1,6 @@ +import * as dayjs from 'dayjs' +import * as isBetween from 'dayjs/plugin/isBetween' + +dayjs.extend(isBetween) + +dayjs('2010-10-20').isBetween('2010-10-19', dayjs('2010-10-25')) === true diff --git a/test/plugin/isLeapYear.d.test.ts b/test/plugin/isLeapYear.d.test.ts new file mode 100644 index 000000000..399930658 --- /dev/null +++ b/test/plugin/isLeapYear.d.test.ts @@ -0,0 +1,6 @@ +import * as dayjs from 'dayjs' +import * as isLeapYear from 'dayjs/plugin/isLeapYear' + +dayjs.extend(isLeapYear) + +dayjs('2010-10-20').isLeapYear() === false diff --git a/test/plugin/relativeTime.d.test.ts b/test/plugin/relativeTime.d.test.ts new file mode 100644 index 000000000..1124553f0 --- /dev/null +++ b/test/plugin/relativeTime.d.test.ts @@ -0,0 +1,20 @@ +import * as dayjs from 'dayjs' +import * as relativeTime from 'dayjs/plugin/relativeTime' + +dayjs.extend(relativeTime) + +dayjs().fromNow().trim() +dayjs().fromNow(true).trim() + +dayjs().from(dayjs()).trim() +dayjs().from(123, true).trim() +dayjs().from('2018-01-23').trim() +dayjs().from(new Date(), true).trim() + +dayjs().toNow().trim() +dayjs().toNow(true).trim() + +dayjs().to(dayjs()).trim() +dayjs().to(123, true).trim() +dayjs().to('2018-01-23').trim() +dayjs().to(new Date(), true).trim() diff --git a/test/plugin/weekOfYear.d.test.ts b/test/plugin/weekOfYear.d.test.ts new file mode 100644 index 000000000..bfaceede9 --- /dev/null +++ b/test/plugin/weekOfYear.d.test.ts @@ -0,0 +1,6 @@ +import * as dayjs from 'dayjs' +import * as weekOfYear from 'dayjs/plugin/weekOfYear' + +dayjs.extend(weekOfYear) + +dayjs('2010-10-20').week() === 43 diff --git a/types/plugin/advancedFormat.d.ts b/types/plugin/advancedFormat.d.ts new file mode 100644 index 000000000..30ec75e5d --- /dev/null +++ b/types/plugin/advancedFormat.d.ts @@ -0,0 +1,4 @@ +import { PluginFunc } from 'dayjs' + +declare const plugin: PluginFunc +export = plugin diff --git a/types/plugin/buddhistEra.d.ts b/types/plugin/buddhistEra.d.ts new file mode 100644 index 000000000..30ec75e5d --- /dev/null +++ b/types/plugin/buddhistEra.d.ts @@ -0,0 +1,4 @@ +import { PluginFunc } from 'dayjs' + +declare const plugin: PluginFunc +export = plugin diff --git a/types/plugin/isBetween.d.ts b/types/plugin/isBetween.d.ts new file mode 100644 index 000000000..41afb64cf --- /dev/null +++ b/types/plugin/isBetween.d.ts @@ -0,0 +1,10 @@ +import { PluginFunc, DateType } from 'dayjs' + +declare const plugin: PluginFunc +export = plugin + +declare module 'dayjs' { + interface Dayjs { + isBetween(a: DateType, b: DateType): boolean + } +} diff --git a/types/plugin/isLeapYear.d.ts b/types/plugin/isLeapYear.d.ts new file mode 100644 index 000000000..5be74092b --- /dev/null +++ b/types/plugin/isLeapYear.d.ts @@ -0,0 +1,10 @@ +import { PluginFunc } from 'dayjs' + +declare const plugin: PluginFunc +export = plugin + +declare module 'dayjs' { + interface Dayjs { + isLeapYear(): boolean + } +} diff --git a/types/plugin/relativeTime.d.ts b/types/plugin/relativeTime.d.ts new file mode 100644 index 000000000..306493002 --- /dev/null +++ b/types/plugin/relativeTime.d.ts @@ -0,0 +1,13 @@ +import { PluginFunc, DateType } from 'dayjs' + +declare const plugin: PluginFunc +export = plugin + +declare module 'dayjs' { + interface Dayjs { + fromNow(withoutSuffix?: boolean): string + from(compared: DateType, withoutSuffix?: boolean): string + toNow(withoutSuffix?: boolean): string + to(compared: DateType, withoutSuffix?: boolean): string + } +} diff --git a/types/plugin/weekOfYear.d.ts b/types/plugin/weekOfYear.d.ts new file mode 100644 index 000000000..360219556 --- /dev/null +++ b/types/plugin/weekOfYear.d.ts @@ -0,0 +1,10 @@ +import { PluginFunc } from 'dayjs' + +declare const plugin: PluginFunc +export = plugin + +declare module 'dayjs' { + interface Dayjs { + week(): number + } +}