mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-23 12:57:25 +08:00
Merge pull request #11024 from alitaheri/add-moment-jalaali
[types 2.0] Add moment-jalaali types
This commit is contained in:
44
moment-jalaali/index.d.ts
vendored
Normal file
44
moment-jalaali/index.d.ts
vendored
Normal 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;
|
||||
}
|
||||
|
||||
}
|
||||
45
moment-jalaali/moment-jalaali-tests.ts
Normal file
45
moment-jalaali/moment-jalaali-tests.ts
Normal 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');
|
||||
5
moment-jalaali/package.json
Normal file
5
moment-jalaali/package.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"moment": "2.14.*"
|
||||
}
|
||||
}
|
||||
19
moment-jalaali/tsconfig.json
Normal file
19
moment-jalaali/tsconfig.json
Normal 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"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user