forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🤖 Merge PR DefinitelyTyped#48898 update(date-arithmetic): version 4 u…
…pdates by @peterblazejewicz * update(date-arithmetic): version 4 updates - simplify module definition - add missing and new methods - correct 'seconds' constant - amend tests - add maintainer https://github.com/jquense/date-math/releases/tag/v4.1.0 Thanks! * Update types/date-arithmetic/index.d.ts Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> * Update types/date-arithmetic/index.d.ts * Update types/date-arithmetic/index.d.ts Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
- Loading branch information
1 parent
09d10b6
commit 0a92f51
Showing
3 changed files
with
103 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,77 @@ | ||
// Type definitions for date-arithmetic v3.1.0 | ||
// Type definitions for date-arithmetic 4.1 | ||
// Project: https://github.com/jquense/date-math | ||
// Definitions by: Sergii Paryzhskyi <https://github.com/HeeL> | ||
// Piotr Błażejewicz <https://github.com/peterblazejewicz> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
|
||
type Unit = 'second' | 'minutes' | 'hours' | 'day' | 'week' | 'month' | 'year' | 'decade' | 'century'; | ||
export type Unit = | ||
| 'milliseconds' | ||
| 'seconds' | ||
| 'minutes' | ||
| 'hours' | ||
| 'day' | ||
| 'week' | ||
| 'month' | ||
| 'year' | ||
| 'decade' | ||
| 'century'; | ||
|
||
/** dateArithmetic Public Instance Methods */ | ||
interface dateArithmeticStatic { | ||
/** Add specified amount of units to a provided date and return new date as a result */ | ||
add(date: Date, num: number, unit: Unit): Date; | ||
export function milliseconds(date: Date): number; | ||
export function milliseconds(date: Date, value: number): Date; | ||
export function seconds(date: Date): number; | ||
export function seconds(date: Date, value: number): Date; | ||
export function minutes(date: Date): number; | ||
export function minutes(date: Date, value: number): Date; | ||
export function hours(date: Date): number; | ||
export function hours(date: Date, value: number): Date; | ||
export function date(date: Date): number; | ||
export function date(date: Date, value: number): Date; | ||
export function day(date: Date): number; | ||
export function day(date: Date, value: number): Date; | ||
export function weekday(date: Date, value: Date): number; | ||
export function weekday(date: Date, value: Date, firstOfWeek: StartOfWeek): Date; | ||
export function month(date: Date): number; | ||
export function month(date: Date, value: number): Date; | ||
export function year(date: Date): number; | ||
export function year(date: Date, value: number): Date; | ||
export function decade(date: Date): number; | ||
export function decade(date: Date, value: number): Date; | ||
export function century(date: Date): number; | ||
export function century(date: Date, value: number): Date; | ||
|
||
/** Subtract specified amount of units from a provided date and return new date as a result */ | ||
subtract(date: Date, num: number, unit: Unit): Date; | ||
/** Add specified amount of units to a provided date and return new date as a result */ | ||
export function add(date: Date, num: number, unit: Unit): Date; | ||
|
||
/** Compare two dates and return true if they are equal */ | ||
eq(date: Date, date2: Date): Boolean; | ||
/** | ||
* The opposite of `startOf` | ||
*/ | ||
export function endOf(date: Date, unit: Unit): Date; | ||
/** | ||
* Return a new date with the relevent date parts zero'd out. | ||
* You only need to provide a firstOfWeek when the unit is 'week' | ||
*/ | ||
export function startOf(date: Date, unit: 'week', firtOfWeek: StartOfWeek): Date; | ||
export function startOf(date: Date, unit: Exclude<Unit, 'week'>): Date; | ||
|
||
/** Compare two dates and return false if they are equal */ | ||
neq(date: Date, date2: Date): Boolean; | ||
/** Subtract specified amount of units from a provided date and return new date as a result */ | ||
export function subtract(date: Date, num: number, unit: Unit): Date; | ||
|
||
/** Compare two dates and return true if date is greater than date2 */ | ||
gt(date: Date, date2: Date): Boolean; | ||
/** Compare two dates and return true if they are equal */ | ||
export function eq(date: Date, date2: Date): boolean; | ||
|
||
/** Compare two dates and return true if date is greater or equal than date2 */ | ||
gte(date: Date, date2: Date): Boolean; | ||
/** Compare two dates and return false if they are equal */ | ||
export function neq(date: Date, date2: Date): boolean; | ||
|
||
/** Compare two dates and return true if date is less than date2 */ | ||
lt(date: Date, date2: Date): Boolean; | ||
/** Compare two dates and return true if date is greater than date2 */ | ||
export function gt(date: Date, date2: Date): boolean; | ||
|
||
/** Compare two dates and return true if date is less or equal than date2 */ | ||
lte(date: Date, date2: Date): Boolean; | ||
} | ||
/** Compare two dates and return true if date is greater or equal than date2 */ | ||
export function gte(date: Date, date2: Date): boolean; | ||
|
||
declare module 'dateArithmetic' { | ||
const dateArithmetic: dateArithmeticStatic; | ||
export = dateArithmetic; | ||
} | ||
/** Compare two dates and return true if date is less than date2 */ | ||
export function lt(date: Date, date2: Date): boolean; | ||
|
||
/** Compare two dates and return true if date is less or equal than date2 */ | ||
export function lte(date: Date, date2: Date): boolean; | ||
|
||
export type StartOfWeek = 0 | 1 | 2 | 3 | 4 | 5 | 6; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
{ | ||
"extends": "dtslint/dt.json", | ||
"rules": { | ||
"ban-types": false, | ||
"dt-header": false, | ||
"no-single-declare-module": false | ||
} | ||
"extends": "dtslint/dt.json" | ||
} |