Merge pull request #11024 from alitaheri/add-moment-jalaali

[types 2.0] Add moment-jalaali types
This commit is contained in:
Andy
2016-09-24 07:59:23 -07:00
committed by GitHub
4 changed files with 113 additions and 0 deletions

44
moment-jalaali/index.d.ts vendored Normal file
View File

@@ -0,0 +1,44 @@
// Type definitions for moment-jalaali 0.5.0
// Project: https://github.com/jalaali/moment-jalaali
// Definitions by: Ali Taheri Moghaddar <https://github.com/alitaheri>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import * as moment from 'moment';
export = moment;
declare module 'moment' {
type JUnitOfTime = 'jYear' | 'jMonth';
/**
* Add persian language.
*/
function loadPersian(): 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;
}
}

View File

@@ -0,0 +1,45 @@
import * as moment from 'moment-jalaali';
moment.loadPersian();
moment.jIsLeapYear(1391);
moment.jDaysInMonth(1395, 11);
const m = moment();
m.jYear();
m.jMonth();
m.jDate();
m.jDayOfYear();
m.jWeek();
m.jWeekYear();
m.jYear(1);
m.jMonth(1);
m.jDate(1);
m.jDayOfYear(1);
m.jWeek(1);
m.jWeekYear(1);
m.startOf('jYear');
m.startOf('jMonth');
m.endOf('jMonth');
m.endOf('jYear');
m.add(1, 'jYear');
m.add(2, 'jMonth');
m.add(3, 'day');
m.add('1', 'jYear');
m.add('2', 'jMonth');
m.add('3', 'day');
m.subtract(1, 'jYear');
m.subtract(2, 'jMonth');
m.subtract(3, 'day');
m.subtract('1', 'jYear');
m.subtract('2', 'jMonth');
m.subtract('3', 'day');

View File

@@ -0,0 +1,5 @@
{
"dependencies": {
"moment": "2.14.*"
}
}

View File

@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"moment-jalaali-tests.ts"
]
}