@hardlydifficult/date-time 1.0.12 → 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.
Files changed (2) hide show
  1. package/README.md +21 -18
  2. package/package.json +1 -1
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
- const milliseconds = toMilliseconds(duration); // 120_000
16
+ const duration: TimeSpan = { value: 2.5, unit: "minutes" };
17
+ console.log(toMilliseconds(duration)); // 150_000
18
18
  ```
19
19
 
20
- ## TimeSpan Conversion
20
+ ## Time Spans
21
21
 
22
- Converts a time duration (represented as a `TimeSpan`) to its equivalent value in milliseconds.
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
- | Property | Type | Description |
27
- |----------|----------|----------------------------|
28
- | `value` | `number` | The numeric value of time |
29
- | `unit` | `TimeUnit` | The time unit (see below) |
26
+ | Field | Type | Description |
27
+ |-------|-----------|----------------------|
28
+ | value | `number` | Numeric duration |
29
+ | unit | `TimeUnit`| Time unit identifier |
30
30
 
31
- ### TimeUnit Options
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
- ### Function
40
+ ### `toMilliseconds`
41
+
42
+ Converts a `TimeSpan` to its equivalent value in milliseconds.
40
43
 
41
44
  ```typescript
42
- toMilliseconds(timeSpan: TimeSpan): number
43
- ```
45
+ import { toMilliseconds } from "@hardlydifficult/date-time";
44
46
 
45
- Converts the given time span to milliseconds using predefined unit multipliers.
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
- ### Examples
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.12",
3
+ "version": "1.0.13",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "files": [