ortus 0.1.1 → 0.1.2
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/index.d.ts +74 -6
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1,16 +1,84 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* PRT unit:
|
|
3
|
+
* - `'ms'` milliseconds (official PRT unit)
|
|
4
|
+
* - `'s'` seconds
|
|
5
|
+
* - `'m'` minutes
|
|
6
|
+
* - `'h'` hours
|
|
7
|
+
* - `'d'` days, always 86,400,000 ms
|
|
8
|
+
* - `'w'` weeks, always 7 days
|
|
9
|
+
*/
|
|
2
10
|
export type Unit = 'ms' | 's' | 'm' | 'h' | 'd' | 'w'
|
|
3
11
|
|
|
12
|
+
/**
|
|
13
|
+
* PRT (Planet Renox Time): milliseconds since `1998-03-14T03:00:00.000Z`.
|
|
14
|
+
*
|
|
15
|
+
* - Results are integers, rounded down toward −∞ (`1.5s → 1`, `-1.5s → -2`).
|
|
16
|
+
* - Times before the epoch are negative.
|
|
17
|
+
* - Exact across the full JS `Date` range (±275,000 years). Outside it throws.
|
|
18
|
+
* - Leap seconds are ignored, the same as JS `Date`.
|
|
19
|
+
*/
|
|
4
20
|
export declare const PRT: Readonly<{
|
|
5
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Current PRT.
|
|
23
|
+
* @param unit Unit to return. Default `'ms'`.
|
|
24
|
+
* @returns Integer PRT, rounded down.
|
|
25
|
+
* @throws {RangeError} Unknown unit.
|
|
26
|
+
* @example
|
|
27
|
+
* PRT.now() // ms
|
|
28
|
+
* PRT.now('d') // days
|
|
29
|
+
*/
|
|
6
30
|
now(unit?: Unit): number
|
|
7
|
-
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* PRT at a `Date`.
|
|
34
|
+
* @param date A valid `Date`. Anything else throws, including numbers.
|
|
35
|
+
* @param unit Unit to return. Default `'ms'`.
|
|
36
|
+
* @returns Integer PRT, rounded down.
|
|
37
|
+
* @throws {TypeError} `date` is not a valid `Date`.
|
|
38
|
+
* @throws {RangeError} Unknown unit.
|
|
39
|
+
* @example
|
|
40
|
+
* PRT.fromDate(new Date('1998-03-14T03:00:00Z')) // 0
|
|
41
|
+
* PRT.fromDate(new Date('2010-06-01'), 'd') // 4461
|
|
42
|
+
*/
|
|
8
43
|
fromDate(date: Date, unit?: Unit): number
|
|
9
|
-
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* `Date` at a PRT value.
|
|
47
|
+
* @param value Integer PRT, in `unit`.
|
|
48
|
+
* @param unit Unit of `value`. Default `'ms'`.
|
|
49
|
+
* @returns The `Date` at the start of that PRT `unit`.
|
|
50
|
+
* @throws {TypeError} `value` is not a safe integer.
|
|
51
|
+
* @throws {RangeError} Unknown unit, or result is outside the `Date` range.
|
|
52
|
+
* @example
|
|
53
|
+
* PRT.toDate(0) // 1998-03-14T03:00:00.000Z
|
|
54
|
+
* PRT.toDate(1e9, 's') // 2029-11-20T04:46:40.000Z
|
|
55
|
+
*/
|
|
10
56
|
toDate(value: number, unit?: Unit): Date
|
|
11
|
-
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* PRT at a Unix timestamp in milliseconds, like `Date.now()`. Not Unix seconds.
|
|
60
|
+
* @param unixMs Integer Unix ms, within the `Date` range.
|
|
61
|
+
* @param unit Unit to return. Default `'ms'`.
|
|
62
|
+
* @returns Integer PRT, rounded down.
|
|
63
|
+
* @throws {TypeError} `unixMs` is not an integer.
|
|
64
|
+
* @throws {RangeError} Unknown unit, or `unixMs` is outside the `Date` range.
|
|
65
|
+
* @example
|
|
66
|
+
* PRT.fromUnixMs(889844400000) // 0
|
|
67
|
+
* PRT.fromUnixMs(0, 'd') // -10300
|
|
68
|
+
*/
|
|
12
69
|
fromUnixMs(unixMs: number, unit?: Unit): number
|
|
13
|
-
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Unix timestamp in milliseconds at a PRT value. Same as `PRT.toDate(value, unit).getTime()`.
|
|
73
|
+
* @param value Integer PRT, in `unit`.
|
|
74
|
+
* @param unit Unit of `value`. Default `'ms'`.
|
|
75
|
+
* @returns Integer Unix ms at the start of that PRT `unit`.
|
|
76
|
+
* @throws {TypeError} `value` is not a safe integer.
|
|
77
|
+
* @throws {RangeError} Unknown unit, or result is outside the `Date` range.
|
|
78
|
+
* @example
|
|
79
|
+
* PRT.toUnixMs(0) // 889844400000
|
|
80
|
+
* PRT.toUnixMs(1, 'w') // 890449200000
|
|
81
|
+
*/
|
|
14
82
|
toUnixMs(value: number, unit?: Unit): number
|
|
15
83
|
}>
|
|
16
84
|
|