-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from marcogrcr/master
feat: add typescript typings
- Loading branch information
Showing
2 changed files
with
58 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
interface Timestamp { | ||
/** | ||
* Set to `true` to round all returned timestamps to the second. | ||
* @default false | ||
*/ | ||
round: boolean; | ||
|
||
/** | ||
* Gets the current time as Unix timestamp. | ||
* Optionally applying a given offset specified as either a human-readable string or a number of | ||
* seconds. | ||
* | ||
* @param offset The optional time offset to apply | ||
* @returns The corresponding timestamp | ||
*/ | ||
now(offset?: string | number): number; | ||
|
||
/** | ||
* Applies the given offset to the given timestamp. | ||
* The offset is specified as either a human-readable string or a number of | ||
* seconds. | ||
* | ||
* @param time The original timestamp | ||
* @param offset The time offset to apply | ||
* @returns The result timestamp | ||
*/ | ||
add(time: number, offset: string | number): number; | ||
|
||
/** | ||
* Gets the offset timestamp for the given offset string. | ||
* (Alias for .add() using a time of zero.) | ||
* | ||
* @param offset The time offset for the duration | ||
* @returns The result time offset | ||
*/ | ||
duration(offset: string | number): number; | ||
|
||
/** | ||
* Gets the Unix timestamp for the given date object or string. | ||
* | ||
* @param date A date object or an ISO 8601 date string | ||
* @returns The corresponding timestamp | ||
*/ | ||
fromDate(date: Date | string): number; | ||
|
||
/** | ||
* Gets the date for the given Unix timestamp. | ||
* | ||
* @param time A timestamp | ||
* @returns The corresponding date | ||
*/ | ||
toDate(time: number): Date; | ||
} | ||
|
||
declare const timestamp: Timestamp; | ||
|
||
export = timestamp; |
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