@hardlydifficult/date-time 1.0.11 → 1.0.13
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/README.md +21 -18
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -13,46 +13,49 @@ npm install @hardlydifficult/date-time
|
|
|
13
13
|
```typescript
|
|
14
14
|
import { toMilliseconds, type TimeSpan } from "@hardlydifficult/date-time";
|
|
15
15
|
|
|
16
|
-
const duration: TimeSpan = { value: 2, unit: "minutes" };
|
|
17
|
-
|
|
16
|
+
const duration: TimeSpan = { value: 2.5, unit: "minutes" };
|
|
17
|
+
console.log(toMilliseconds(duration)); // 150_000
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
##
|
|
20
|
+
## Time Spans
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
Represents a time duration with a numeric `value` and a `unit`, and converts it to milliseconds.
|
|
23
23
|
|
|
24
|
-
### Interface
|
|
24
|
+
### `TimeSpan` Interface
|
|
25
25
|
|
|
26
|
-
|
|
|
27
|
-
|
|
28
|
-
|
|
|
29
|
-
|
|
|
26
|
+
| Field | Type | Description |
|
|
27
|
+
|-------|-----------|----------------------|
|
|
28
|
+
| value | `number` | Numeric duration |
|
|
29
|
+
| unit | `TimeUnit`| Time unit identifier |
|
|
30
30
|
|
|
31
|
-
### TimeUnit
|
|
31
|
+
### `TimeUnit` Type
|
|
32
32
|
|
|
33
|
+
Supported units:
|
|
33
34
|
- `"milliseconds"`
|
|
34
35
|
- `"seconds"`
|
|
35
36
|
- `"minutes"`
|
|
36
37
|
- `"hours"`
|
|
37
38
|
- `"days"`
|
|
38
39
|
|
|
39
|
-
###
|
|
40
|
+
### `toMilliseconds`
|
|
41
|
+
|
|
42
|
+
Converts a `TimeSpan` to its equivalent value in milliseconds.
|
|
40
43
|
|
|
41
44
|
```typescript
|
|
42
|
-
toMilliseconds
|
|
43
|
-
```
|
|
45
|
+
import { toMilliseconds } from "@hardlydifficult/date-time";
|
|
44
46
|
|
|
45
|
-
|
|
47
|
+
toMilliseconds({ value: 1, unit: "hours" }); // 3_600_000
|
|
48
|
+
toMilliseconds({ value: 0.5, unit: "days" }); // 43_200_000
|
|
49
|
+
toMilliseconds({ value: 120, unit: "seconds" }); // 120_000
|
|
50
|
+
```
|
|
46
51
|
|
|
47
|
-
|
|
52
|
+
#### Additional Examples
|
|
48
53
|
|
|
49
54
|
```typescript
|
|
50
|
-
import { toMilliseconds } from "@hardlydifficult/date-time";
|
|
51
|
-
|
|
52
55
|
// Seconds to milliseconds
|
|
53
56
|
toMilliseconds({ value: 2, unit: "seconds" }); // 2_000
|
|
54
57
|
|
|
55
|
-
// Minutes to milliseconds
|
|
58
|
+
// Minutes to milliseconds (fractional value)
|
|
56
59
|
toMilliseconds({ value: 1.5, unit: "minutes" }); // 90_000
|
|
57
60
|
|
|
58
61
|
// Days to milliseconds
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hardlydifficult/date-time",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"vitest": "4.0.18"
|
|
20
20
|
},
|
|
21
21
|
"engines": {
|
|
22
|
-
"node": ">=
|
|
22
|
+
"node": ">=20.19.0"
|
|
23
23
|
},
|
|
24
24
|
"type": "commonjs",
|
|
25
25
|
"exports": {
|