@hardlydifficult/date-time 1.0.8 → 1.0.9

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 +28 -34
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @hardlydifficult/date-time
2
2
 
3
- A TypeScript library for representing time durations and converting them to milliseconds.
3
+ A TypeScript utility for converting time durations to milliseconds with strong typing.
4
4
 
5
5
  ## Installation
6
6
 
@@ -14,50 +14,44 @@ npm install @hardlydifficult/date-time
14
14
  import { toMilliseconds, type TimeSpan } from "@hardlydifficult/date-time";
15
15
 
16
16
  const duration: TimeSpan = { value: 2.5, unit: "minutes" };
17
- const milliseconds = toMilliseconds(duration);
18
- // => 150000
17
+ const ms = toMilliseconds(duration); // 150_000
19
18
  ```
20
19
 
21
- ## Time Duration Conversion
20
+ ## TimeSpan Conversion
22
21
 
23
- ### toMilliseconds
22
+ Converts a time duration to its equivalent in milliseconds using predefined unit multipliers.
24
23
 
25
- Converts a `TimeSpan` to its equivalent value in milliseconds.
24
+ ### `TimeSpan` Interface
26
25
 
27
- ```typescript
28
- import { toMilliseconds, type TimeSpan } from "@hardlydifficult/date-time";
29
-
30
- // Seconds
31
- toMilliseconds({ value: 5, unit: "seconds" }); // => 5000
32
-
33
- // Minutes
34
- toMilliseconds({ value: 1.5, unit: "minutes" }); // => 90000
26
+ Represents a time duration with a numeric `value` and a `unit`.
35
27
 
36
- // Hours
37
- toMilliseconds({ value: 1, unit: "hours" }); // => 3600000
28
+ | Field | Type | Description |
29
+ |-------|----------|----------------------|
30
+ | value | `number` | The numeric duration |
31
+ | unit | `TimeUnit` | The time unit |
38
32
 
39
- // Days
40
- toMilliseconds({ value: 1, unit: "days" }); // => 86400000
33
+ ### `TimeUnit` Type
41
34
 
42
- // Fractional values
43
- toMilliseconds({ value: 0.5, unit: "seconds" }); // => 500
44
- ```
35
+ Supported time units:
36
+ - `"milliseconds"`
37
+ - `"seconds"`
38
+ - `"minutes"`
39
+ - `"hours"`
40
+ - `"days"`
45
41
 
46
- ### TimeSpan Interface
42
+ ### `toMilliseconds(timeSpan)`
47
43
 
48
- Represents a duration with a numeric value and a unit.
44
+ Converts a `TimeSpan` to milliseconds.
49
45
 
50
- | Property | Type | Description |
51
- |----------|----------|-------------------------|
52
- | value | `number` | The numeric duration |
53
- | unit | `TimeUnit` | The time unit (see below) |
46
+ ```typescript
47
+ import { toMilliseconds } from "@hardlydifficult/date-time";
54
48
 
55
- ### TimeUnit Type
49
+ // Convert 2 hours
50
+ toMilliseconds({ value: 2, unit: "hours" }); // 7_200_000
56
51
 
57
- Supported time units:
52
+ // Convert 0.5 days
53
+ toMilliseconds({ value: 0.5, unit: "days" }); // 43_200_000
58
54
 
59
- - `"milliseconds"`
60
- - `"seconds"`
61
- - `"minutes"`
62
- - `"hours"`
63
- - `"days"`
55
+ // Handle fractional values
56
+ toMilliseconds({ value: 1.5, unit: "minutes" }); // 90_000
57
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hardlydifficult/date-time",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "files": [