@sapphire/time-utilities 1.7.6-next.fca7a80.0 → 1.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/index.d.ts +261 -7
- package/dist/index.global.js +95 -59
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +35 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -5
- package/dist/lib/Cron.d.ts +0 -40
- package/dist/lib/Duration.d.ts +0 -41
- package/dist/lib/DurationFormatter.d.ts +0 -28
- package/dist/lib/TimerManager.d.ts +0 -43
- package/dist/lib/Timestamp.d.ts +0 -88
- package/dist/lib/constants.d.ts +0 -61
package/dist/lib/Duration.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Converts duration strings into ms and future dates
|
|
3
|
-
*/
|
|
4
|
-
export declare class Duration {
|
|
5
|
-
/**
|
|
6
|
-
* The offset
|
|
7
|
-
*/
|
|
8
|
-
offset: number;
|
|
9
|
-
/**
|
|
10
|
-
* Create a new Duration instance
|
|
11
|
-
* @param pattern The string to parse
|
|
12
|
-
*/
|
|
13
|
-
constructor(pattern: string);
|
|
14
|
-
/**
|
|
15
|
-
* Get the date from now
|
|
16
|
-
*/
|
|
17
|
-
get fromNow(): Date;
|
|
18
|
-
/**
|
|
19
|
-
* Get the date from
|
|
20
|
-
* @param date The Date instance to get the date from
|
|
21
|
-
*/
|
|
22
|
-
dateFrom(date: Date): Date;
|
|
23
|
-
/**
|
|
24
|
-
* The RegExp used for the pattern parsing
|
|
25
|
-
*/
|
|
26
|
-
private static readonly kPatternRegex;
|
|
27
|
-
/**
|
|
28
|
-
* The RegExp used for removing commas
|
|
29
|
-
*/
|
|
30
|
-
private static readonly kCommaRegex;
|
|
31
|
-
/**
|
|
32
|
-
* The RegExp used for replacing a/an with 1
|
|
33
|
-
*/
|
|
34
|
-
private static readonly kAanRegex;
|
|
35
|
-
/**
|
|
36
|
-
* Parse the pattern
|
|
37
|
-
* @param pattern The pattern to parse
|
|
38
|
-
*/
|
|
39
|
-
private static parse;
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=Duration.d.ts.map
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { TimeTypes } from './constants';
|
|
2
|
-
/**
|
|
3
|
-
* Display the duration
|
|
4
|
-
* @param duration The duration in milliseconds to parse and display
|
|
5
|
-
* @param assets The language assets
|
|
6
|
-
*/
|
|
7
|
-
export declare class DurationFormatter {
|
|
8
|
-
units: DurationFormatAssetsTime;
|
|
9
|
-
constructor(units?: DurationFormatAssetsTime);
|
|
10
|
-
format(duration: number, precision?: number, { left: leftSeparator, right: rightSeparator }?: DurationFormatSeparators): string;
|
|
11
|
-
}
|
|
12
|
-
export interface DurationFormatSeparators {
|
|
13
|
-
left?: string;
|
|
14
|
-
right?: string;
|
|
15
|
-
}
|
|
16
|
-
export interface DurationFormatAssetsUnit extends Record<number, string> {
|
|
17
|
-
DEFAULT: string;
|
|
18
|
-
}
|
|
19
|
-
export interface DurationFormatAssetsTime {
|
|
20
|
-
[TimeTypes.Second]: DurationFormatAssetsUnit;
|
|
21
|
-
[TimeTypes.Minute]: DurationFormatAssetsUnit;
|
|
22
|
-
[TimeTypes.Hour]: DurationFormatAssetsUnit;
|
|
23
|
-
[TimeTypes.Day]: DurationFormatAssetsUnit;
|
|
24
|
-
[TimeTypes.Week]: DurationFormatAssetsUnit;
|
|
25
|
-
[TimeTypes.Month]: DurationFormatAssetsUnit;
|
|
26
|
-
[TimeTypes.Year]: DurationFormatAssetsUnit;
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=DurationFormatter.d.ts.map
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/**
|
|
3
|
-
* Manages timers so that this application can be cleanly exited
|
|
4
|
-
*/
|
|
5
|
-
export declare class TimerManager extends null {
|
|
6
|
-
/**
|
|
7
|
-
* A set of timeouts to clear on destroy
|
|
8
|
-
*/
|
|
9
|
-
private static storedTimeouts;
|
|
10
|
-
/**
|
|
11
|
-
* A set of intervals to clear on destroy
|
|
12
|
-
*/
|
|
13
|
-
private static storedIntervals;
|
|
14
|
-
/**
|
|
15
|
-
* Creates a timeout gets cleared when destroyed
|
|
16
|
-
* @param fn callback function
|
|
17
|
-
* @param delay amount of time before running the callback
|
|
18
|
-
* @param args additional arguments to pass back to the callback
|
|
19
|
-
*/
|
|
20
|
-
static setTimeout<A = unknown>(fn: (...args: A[]) => void, delay: number, ...args: A[]): NodeJS.Timeout;
|
|
21
|
-
/**
|
|
22
|
-
* Clears a timeout created through this class
|
|
23
|
-
* @param timeout The timeout to clear
|
|
24
|
-
*/
|
|
25
|
-
static clearTimeout(timeout: NodeJS.Timeout): void;
|
|
26
|
-
/**
|
|
27
|
-
* Creates an interval gets cleared when destroyed
|
|
28
|
-
* @param fn callback function
|
|
29
|
-
* @param delay amount of time before running the callback
|
|
30
|
-
* @param args additional arguments to pass back to the callback
|
|
31
|
-
*/
|
|
32
|
-
static setInterval<A = unknown>(fn: (...args: A[]) => void, delay: number, ...args: A[]): NodeJS.Timeout;
|
|
33
|
-
/**
|
|
34
|
-
* Clears an internal created through this class
|
|
35
|
-
* @param interval The interval to clear
|
|
36
|
-
*/
|
|
37
|
-
static clearInterval(interval: NodeJS.Timeout): void;
|
|
38
|
-
/**
|
|
39
|
-
* Clears running timeouts and intervals created through this class so NodeJS can gracefully exit
|
|
40
|
-
*/
|
|
41
|
-
static destroy(): void;
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=TimerManager.d.ts.map
|
package/dist/lib/Timestamp.d.ts
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
export declare type TimeResolvable = Date | number | string;
|
|
2
|
-
export interface TimestampTemplateEntry {
|
|
3
|
-
type: string;
|
|
4
|
-
content: string | null;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Timestamp class, parses the pattern once, displays the desired Date or UNIX timestamp with the selected pattern.
|
|
8
|
-
*/
|
|
9
|
-
export declare class Timestamp {
|
|
10
|
-
/**
|
|
11
|
-
* The raw pattern
|
|
12
|
-
* @since 1.0.0
|
|
13
|
-
*/
|
|
14
|
-
pattern: string;
|
|
15
|
-
/**
|
|
16
|
-
* @since 1.0.0
|
|
17
|
-
*/
|
|
18
|
-
private template;
|
|
19
|
-
/**
|
|
20
|
-
* Starts a new Timestamp and parses the pattern.
|
|
21
|
-
* @since 1.0.0
|
|
22
|
-
* @param pattern The pattern to parse
|
|
23
|
-
*/
|
|
24
|
-
constructor(pattern: string);
|
|
25
|
-
/**
|
|
26
|
-
* Display the current date with the current pattern.
|
|
27
|
-
* @since 1.0.0
|
|
28
|
-
* @param time The time to display
|
|
29
|
-
*/
|
|
30
|
-
display(time?: TimeResolvable): string;
|
|
31
|
-
/**
|
|
32
|
-
* Display the current date utc with the current pattern.
|
|
33
|
-
* @since 1.0.0
|
|
34
|
-
* @param time The time to display in utc
|
|
35
|
-
*/
|
|
36
|
-
displayUTC(time?: TimeResolvable): string;
|
|
37
|
-
/**
|
|
38
|
-
* Edits the current pattern.
|
|
39
|
-
* @since 1.0.0
|
|
40
|
-
* @param pattern The new pattern for this instance
|
|
41
|
-
* @chainable
|
|
42
|
-
*/
|
|
43
|
-
edit(pattern: string): this;
|
|
44
|
-
/**
|
|
45
|
-
* Defines the toString behavior of Timestamp.
|
|
46
|
-
*/
|
|
47
|
-
toString(): string;
|
|
48
|
-
/**
|
|
49
|
-
* Display the current date with the current pattern.
|
|
50
|
-
* @since 1.0.0
|
|
51
|
-
* @param pattern The pattern to parse
|
|
52
|
-
* @param time The time to display
|
|
53
|
-
*/
|
|
54
|
-
static displayArbitrary(pattern: string, time?: TimeResolvable): string;
|
|
55
|
-
/**
|
|
56
|
-
* Display the current date utc with the current pattern.
|
|
57
|
-
* @since 1.0.0
|
|
58
|
-
* @param pattern The pattern to parse
|
|
59
|
-
* @param time The time to display
|
|
60
|
-
*/
|
|
61
|
-
static displayUTCArbitrary(pattern: string, time?: TimeResolvable): string;
|
|
62
|
-
/**
|
|
63
|
-
* Creates a UTC Date object to work with.
|
|
64
|
-
* @since 1.0.0
|
|
65
|
-
* @param time The date to convert to utc
|
|
66
|
-
*/
|
|
67
|
-
static utc(time?: Date | number | string): Date;
|
|
68
|
-
/**
|
|
69
|
-
* Display the current date with the current pattern.
|
|
70
|
-
* @since 1.0.0
|
|
71
|
-
* @param template The pattern to parse
|
|
72
|
-
* @param time The time to display
|
|
73
|
-
*/
|
|
74
|
-
private static display;
|
|
75
|
-
/**
|
|
76
|
-
* Parses the pattern.
|
|
77
|
-
* @since 1.0.0
|
|
78
|
-
* @param pattern The pattern to parse
|
|
79
|
-
*/
|
|
80
|
-
private static parse;
|
|
81
|
-
/**
|
|
82
|
-
* Resolves a date.
|
|
83
|
-
* @since 1.0.0
|
|
84
|
-
* @param time The time to parse
|
|
85
|
-
*/
|
|
86
|
-
private static resolveDate;
|
|
87
|
-
}
|
|
88
|
-
//# sourceMappingURL=Timestamp.d.ts.map
|
package/dist/lib/constants.d.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { DurationFormatAssetsTime, DurationFormatSeparators } from './DurationFormatter';
|
|
2
|
-
/**
|
|
3
|
-
* The supported time types
|
|
4
|
-
*/
|
|
5
|
-
export declare enum TimeTypes {
|
|
6
|
-
Second = "second",
|
|
7
|
-
Minute = "minute",
|
|
8
|
-
Hour = "hour",
|
|
9
|
-
Day = "day",
|
|
10
|
-
Week = "week",
|
|
11
|
-
Month = "month",
|
|
12
|
-
Year = "year"
|
|
13
|
-
}
|
|
14
|
-
export declare enum Time {
|
|
15
|
-
Millisecond = 1,
|
|
16
|
-
Second = 1000,
|
|
17
|
-
Minute = 60000,
|
|
18
|
-
Hour = 3600000,
|
|
19
|
-
Day = 86400000,
|
|
20
|
-
Month = 2628000000,
|
|
21
|
-
Year = 31536000000
|
|
22
|
-
}
|
|
23
|
-
export declare const days: string[];
|
|
24
|
-
export declare const months: string[];
|
|
25
|
-
export declare const tokens: Map<string, number>;
|
|
26
|
-
export declare const partRegex: RegExp;
|
|
27
|
-
export declare const wildcardRegex: RegExp;
|
|
28
|
-
export declare const allowedNum: number[][];
|
|
29
|
-
export declare const predefined: {
|
|
30
|
-
readonly '@annually': "0 0 1 1 *";
|
|
31
|
-
readonly '@yearly': "0 0 1 1 *";
|
|
32
|
-
readonly '@monthly': "0 0 1 * *";
|
|
33
|
-
readonly '@weekly': "0 0 * * 0";
|
|
34
|
-
readonly '@daily': "0 0 * * *";
|
|
35
|
-
readonly '@hourly': "0 * * * *";
|
|
36
|
-
};
|
|
37
|
-
export declare const cronTokens: {
|
|
38
|
-
readonly jan: 1;
|
|
39
|
-
readonly feb: 2;
|
|
40
|
-
readonly mar: 3;
|
|
41
|
-
readonly apr: 4;
|
|
42
|
-
readonly may: 5;
|
|
43
|
-
readonly jun: 6;
|
|
44
|
-
readonly jul: 7;
|
|
45
|
-
readonly aug: 8;
|
|
46
|
-
readonly sep: 9;
|
|
47
|
-
readonly oct: 10;
|
|
48
|
-
readonly nov: 11;
|
|
49
|
-
readonly dec: 12;
|
|
50
|
-
readonly sun: 0;
|
|
51
|
-
readonly mon: 1;
|
|
52
|
-
readonly tue: 2;
|
|
53
|
-
readonly wed: 3;
|
|
54
|
-
readonly thu: 4;
|
|
55
|
-
readonly fri: 5;
|
|
56
|
-
readonly sat: 6;
|
|
57
|
-
};
|
|
58
|
-
export declare const tokensRegex: RegExp;
|
|
59
|
-
export declare const DEFAULT_UNITS: DurationFormatAssetsTime;
|
|
60
|
-
export declare const DEFAULT_SEPARATORS: DurationFormatSeparators;
|
|
61
|
-
//# sourceMappingURL=constants.d.ts.map
|