Skip to content

Commit

Permalink
add ts definition
Browse files Browse the repository at this point in the history
  • Loading branch information
hosseinmd committed Sep 4, 2020
1 parent d744c4e commit 354e2a7
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
55 changes: 55 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Type definitions for moment-jalaali 0.7.0
// Project: https://github.com/jalaali/moment-jalaali
// Definitions by: Ali Taheri Moghaddar <https://github.com/alitaheri>
// 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;
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -45,4 +46,4 @@
"moment-timezone": "^0.5.21",
"rimraf": "^2.6.2"
}
}
}

0 comments on commit 354e2a7

Please sign in to comment.