mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 07:40:10 +00:00
Merge pull request #29113 from lukeed/fix/fromnow
Update `fromnow` for 3.x
This commit is contained in:
@@ -1,29 +1,35 @@
|
||||
|
||||
|
||||
import fromnow = require( 'fromnow' );
|
||||
import fromnow = require('fromnow');
|
||||
|
||||
function dateOnly() {
|
||||
fromnow( '2015-12-31' );
|
||||
fromnow('2015-12-31');
|
||||
}
|
||||
|
||||
function dateObjectOnly() {
|
||||
fromnow( new Date() );
|
||||
fromnow(new Date());
|
||||
}
|
||||
|
||||
function maxChunks() {
|
||||
fromnow( '2015-12-31', {
|
||||
maxChunks: 12
|
||||
function max() {
|
||||
fromnow('2015-12-31', {
|
||||
max: 12
|
||||
});
|
||||
}
|
||||
|
||||
function useAgo() {
|
||||
fromnow( '2015-12-31', {
|
||||
useAgo: true
|
||||
function suffix() {
|
||||
fromnow('2015-12-31', {
|
||||
suffix: true
|
||||
});
|
||||
}
|
||||
|
||||
function useAnd() {
|
||||
fromnow( '2015-12-31', {
|
||||
useAnd: true
|
||||
function and() {
|
||||
fromnow('2015-12-31', {
|
||||
and: true
|
||||
});
|
||||
}
|
||||
|
||||
function zero() {
|
||||
fromnow('2015-12-31', {
|
||||
zero: true
|
||||
});
|
||||
}
|
||||
|
||||
16
types/fromnow/index.d.ts
vendored
16
types/fromnow/index.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for fromnow v2.0.0
|
||||
// Type definitions for fromnow v3.0.0
|
||||
// Project: https://github.com/lukeed/fromNow
|
||||
// Definitions by: Martin Bukovics <https://github.com/marinewater>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -9,18 +9,20 @@ export as namespace fromNow;
|
||||
|
||||
declare namespace FromNow {
|
||||
interface FromNowOpts {
|
||||
maxChunks?: number,
|
||||
useAgo?: boolean,
|
||||
useAnd?: boolean
|
||||
max?: number,
|
||||
suffix?: boolean,
|
||||
zero?: boolean,
|
||||
and?: boolean
|
||||
}
|
||||
export interface FromNowStatic {
|
||||
/**
|
||||
* Get readable time differences from now vs past or future dates.
|
||||
* @param {string|Date} date
|
||||
* @param {object} [opts]
|
||||
* @param {number} [opts.maxChucks=10]
|
||||
* @param {boolean} [opts.useAgo=false]
|
||||
* @param {boolean} [opts.useAnd=false]
|
||||
* @param {number} [opts.max=Infinity]
|
||||
* @param {boolean} [opts.suffix=false]
|
||||
* @param {boolean} [opts.zero=false]
|
||||
* @param {boolean} [opts.and=false]
|
||||
*/
|
||||
(date: string|Date, opts?: FromNowOpts): string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user