From 354e2a7191772d03069c87fbd5203f0be03b2903 Mon Sep 17 00:00:00 2001 From: Hossein Mohammadi Date: Fri, 4 Sep 2020 14:53:05 +0430 Subject: [PATCH] add ts definition --- index.d.ts | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 3 ++- 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..467c2db --- /dev/null +++ b/index.d.ts @@ -0,0 +1,55 @@ +// Type definitions for moment-jalaali 0.7.0 +// Project: https://github.com/jalaali/moment-jalaali +// Definitions by: Ali Taheri Moghaddar +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import moment = require("moment"); + +export = moment; + +declare module "moment" { + type JUnitOfTime = "jYear" | "jMonth"; + + interface LoadPersianOptions { + /** + * Use persian digits as decribed by unicode + */ + usePersianDigits?: boolean; + /** + * use dialect option to change usePersian dialect, available options are: + * persian: default dialect(امرداد، آدینه، ...) + * persian-modern: modern dialect(مرداد، جمعه، ...) + */ + dialect?: "persian" | "persian-modern"; + } + + /** + * Add persian language. + */ + function loadPersian(options?: LoadPersianOptions): void; + + function jIsLeapYear(year: number): boolean; + function jDaysInMonth(year: number, month: number): number; + + interface Moment { + startOf(jUnitOfTime: JUnitOfTime): Moment; + endOf(jUnitOfTime: JUnitOfTime): Moment; + + add(amount: string | number, jUnitOfTime: JUnitOfTime): Moment; + + subtract(amount: string | number, jUnitOfTime: JUnitOfTime): Moment; + + jYear(y: number): Moment; + jYear(): number; + jMonth(M: number | string): Moment; + jMonth(): number; + jDate(d: number): Moment; + jDate(): number; + jWeek(d: number): Moment; + jWeek(): number; + jWeekYear(d: number): Moment; + jWeekYear(): number; + jDayOfYear(d: number): Moment; + jDayOfYear(): number; + } +} diff --git a/package.json b/package.json index 2a2a5e8..2eb3684 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "convert" ], "main": "index.js", + "types": "index.d.ts", "scripts": { "test": "mocha --reporter spec --ui bdd --colors --check-leaks test.js", "lint": "eslint index.js && eslint --env mocha --rule 'no-unused-expressions: 0' test.js", @@ -45,4 +46,4 @@ "moment-timezone": "^0.5.21", "rimraf": "^2.6.2" } -} +} \ No newline at end of file