@hardlydifficult/date-time 1.0.10 → 1.0.11

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.
Files changed (2) hide show
  1. package/README.md +29 -20
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -13,45 +13,54 @@ 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.5, unit: "minutes" };
17
- const ms = toMilliseconds(duration); // 150_000
16
+ const duration: TimeSpan = { value: 2, unit: "minutes" };
17
+ const milliseconds = toMilliseconds(duration); // 120_000
18
18
  ```
19
19
 
20
20
  ## TimeSpan Conversion
21
21
 
22
- Converts a time duration to its equivalent in milliseconds using predefined unit multipliers.
22
+ Converts a time duration (represented as a `TimeSpan`) to its equivalent value in milliseconds.
23
23
 
24
- ### `TimeSpan` Interface
24
+ ### Interface
25
25
 
26
- Represents a time duration with a numeric `value` and a `unit`.
26
+ | Property | Type | Description |
27
+ |----------|----------|----------------------------|
28
+ | `value` | `number` | The numeric value of time |
29
+ | `unit` | `TimeUnit` | The time unit (see below) |
27
30
 
28
- | Field | Type | Description |
29
- |-------|----------|----------------------|
30
- | value | `number` | The numeric duration |
31
- | unit | `TimeUnit` | The time unit |
31
+ ### TimeUnit Options
32
32
 
33
- ### `TimeUnit` Type
34
-
35
- Supported time units:
36
33
  - `"milliseconds"`
37
34
  - `"seconds"`
38
35
  - `"minutes"`
39
36
  - `"hours"`
40
37
  - `"days"`
41
38
 
42
- ### `toMilliseconds(timeSpan)`
39
+ ### Function
40
+
41
+ ```typescript
42
+ toMilliseconds(timeSpan: TimeSpan): number
43
+ ```
44
+
45
+ Converts the given time span to milliseconds using predefined unit multipliers.
43
46
 
44
- Converts a `TimeSpan` to milliseconds.
47
+ ### Examples
45
48
 
46
49
  ```typescript
47
50
  import { toMilliseconds } from "@hardlydifficult/date-time";
48
51
 
49
- // Convert 2 hours
50
- toMilliseconds({ value: 2, unit: "hours" }); // 7_200_000
52
+ // Seconds to milliseconds
53
+ toMilliseconds({ value: 2, unit: "seconds" }); // 2_000
51
54
 
52
- // Convert 0.5 days
53
- toMilliseconds({ value: 0.5, unit: "days" }); // 43_200_000
54
-
55
- // Handle fractional values
55
+ // Minutes to milliseconds
56
56
  toMilliseconds({ value: 1.5, unit: "minutes" }); // 90_000
57
+
58
+ // Days to milliseconds
59
+ toMilliseconds({ value: 1, unit: "days" }); // 86_400_000
60
+
61
+ // Fractional value
62
+ toMilliseconds({ value: 0.5, unit: "seconds" }); // 500
63
+
64
+ // Zero duration
65
+ toMilliseconds({ value: 0, unit: "hours" }); // 0
57
66
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hardlydifficult/date-time",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "files": [