Added declaration of moment-shortformat

This commit is contained in:
whatasoda
2018-06-12 18:40:53 +09:00
parent 3b8b13474e
commit 1d2f4b6585
4 changed files with 60 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
// Type definitions for moment-shortformat 2.1
// Project: https://github.com/researchgate/moment-shortformat#readme
// Definitions by: whatasoda <https://github.com/whatasoda>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export as namespace moment;
import moment = require('moment');
export = moment;
declare module 'moment' {
interface Moment {
short(withoutPreOrSuffix?: boolean, now?: Moment): string;
}
}
@@ -0,0 +1,20 @@
import moment = require('moment');
import momentShortformat = require('moment-shortformat');
moment === momentShortformat; // true
/*~ Formats time relative to current time. */
moment(moment().valueOf() + (36e5 * 5)).short(); // in 5h
moment(moment().valueOf() - (36e5 * 5)).short(); // 5h ago
moment(moment().valueOf() + (36e5 * 5)).short(true); // 5h
moment(moment().valueOf() - (36e5 * 5)).short(true); // 5h
/*~ Times greater than 1 week are converted to dates like Mar 7,
*~ or if the year of the date does not match the current year
*~ it is convert to Mar 7, 2031
*/
moment(moment().valueOf() + 6048e5).short(); // Mar 7
/*~ Using a different "now" */
moment(moment().valueOf() + (36e5 * 5))
.short(false, moment(moment().valueOf() + (36e5 * 3))); // in 2h
+23
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-shortformat-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }