mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Add @types/human-date (#42736)
* Add @types/human-date * Change tests filename * Delete human-date.ts * Update human-date-tests.ts * Update index.d.ts * Update index.d.ts * Add files via upload * Add files via upload * Add files via upload
This commit is contained in:
parent
39ac1fd3e7
commit
0d448d3e5d
29
types/human-date/human-date-tests.ts
Normal file
29
types/human-date/human-date-tests.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import hdate = require('human-date');
|
||||
|
||||
// .prertyPrint method
|
||||
hdate.prettyPrint('8-16-1987');
|
||||
hdate.prettyPrint(new Date('8-16-1987'));
|
||||
hdate.prettyPrint(-6400);
|
||||
hdate.prettyPrint(new Date(1416448704578), { showTime: true });
|
||||
|
||||
// .relativeTime method
|
||||
hdate.relativeTime(4);
|
||||
hdate.relativeTime(4, {futureSuffix: "in the future"});
|
||||
hdate.relativeTime("8-16-1987");
|
||||
hdate.relativeTime(new Date("8-16-1987"));
|
||||
hdate.relativeTime(new Date("8-16-1987"), { returnObject: true });
|
||||
hdate.relativeTime(new Date("8-16-1987")).length;
|
||||
hdate.relativeTime(new Date("8-16-1987"), { returnObject: true }).seconds;
|
||||
hdate.relativeTime(75, { allUnits: true });
|
||||
|
||||
// .monthName method
|
||||
hdate.monthName(8);
|
||||
hdate.monthName("8-16-1987");
|
||||
hdate.monthName(new Date("8-16-1987"));
|
||||
|
||||
// .toUTC method
|
||||
hdate.toUTC(1000000000000);
|
||||
hdate.toUTC(1000000000000).getFullYear();
|
||||
hdate.toUTC("8-16-1987");
|
||||
hdate.toUTC(new Date("8-16-1987"));
|
||||
hdate.toUTC(new Date("8-16-1987")).toISOString();
|
||||
47
types/human-date/index.d.ts
vendored
Normal file
47
types/human-date/index.d.ts
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
// Type definitions for human-date 1.4
|
||||
// Project: https://github.com/montanaflynn/human-date
|
||||
// Definitions by: Rico Sandyca Novenza <https://github.com/ricosandyca>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export interface PrettyPrintOptions {
|
||||
showTime?: boolean;
|
||||
}
|
||||
|
||||
export interface RelativeTimeOptions {
|
||||
futureSuffix?: string;
|
||||
pastSuffix?: string;
|
||||
presentText?: string;
|
||||
returnObject?: boolean;
|
||||
allUnits?: boolean;
|
||||
}
|
||||
|
||||
export interface RelativeTimeReturns {
|
||||
seconds: number;
|
||||
hours: number;
|
||||
days: number;
|
||||
years: number;
|
||||
past: boolean;
|
||||
}
|
||||
|
||||
// prettyPrint
|
||||
export function prettyPrint(
|
||||
arg: string | Date | number,
|
||||
options?: PrettyPrintOptions
|
||||
): string;
|
||||
|
||||
// relativeTime
|
||||
export function relativeTime(
|
||||
arg: string | Date | number,
|
||||
options?: RelativeTimeOptions & { returnObject?: false }
|
||||
): string;
|
||||
|
||||
export function relativeTime(
|
||||
arg: string | Date | number,
|
||||
options: RelativeTimeOptions & { returnObject: true }
|
||||
): RelativeTimeReturns;
|
||||
|
||||
// monthName
|
||||
export function monthName(arg: string | Date | number): string;
|
||||
|
||||
// toUTC
|
||||
export function toUTC(arg: string | Date | number): Date;
|
||||
23
types/human-date/tsconfig.json
Normal file
23
types/human-date/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"human-date-tests.ts"
|
||||
]
|
||||
}
|
||||
3
types/human-date/tslint.json
Normal file
3
types/human-date/tslint.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user