Add moment-precise-range-plugin

This commit is contained in:
Mitchell Grice
2019-02-07 15:11:18 +10:00
parent 0b417416fe
commit bc1eb3b28e
5 changed files with 72 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
// Type definitions for moment-precise-range 0.2
// Project: https://github.com/codebox/moment-precise-range
// Definitions by: Mitchell Grice <https://github.com/gricey432>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import moment = require('moment');
export = moment;
declare module "moment" {
interface PreciseRangeValueObject {
years: number;
months: number;
days: number;
hours: number;
minutes: number;
seconds: number;
firstDateWasLater: boolean;
}
interface Moment {
preciseDiff(d2: Moment, returnValueObject?: false): string;
preciseDiff(d2: Moment, returnValueObject: true): PreciseRangeValueObject;
}
function preciseDiff(d1: Moment, d2: Moment, returnValueObject?: false): string;
function preciseDiff(d1: Moment, d2: Moment, returnValueObject: true): PreciseRangeValueObject;
}

View File

@@ -0,0 +1,14 @@
import moment = require("moment");
import * as momentPreciseRange from "moment-precise-range-plugin";
// Static methods
const m1 = moment.utc();
const m2 = moment.utc();
moment.preciseDiff(m1, m2);
moment.preciseDiff(m1, m2, true);
moment.preciseDiff(m1, m2, false);
// Instance methods
m1.preciseDiff(m2);
m1.preciseDiff(m2, true);
m1.preciseDiff(m2, false);

View File

@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"moment": ">=2.14.0"
}
}

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"moment-precise-range-plugin-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }