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