@bgord/tools 1.0.3 → 1.0.4

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.
@@ -6,12 +6,15 @@ export declare class Duration {
6
6
  private static readonly MS_IN_MINUTE;
7
7
  private static readonly MS_IN_HOUR;
8
8
  private static readonly MS_IN_DAY;
9
+ private static readonly MS_IN_WEEK;
9
10
  private constructor();
11
+ static Weeks(value: number): Duration;
10
12
  static Days(value: number): Duration;
11
13
  static Hours(value: number): Duration;
12
14
  static Minutes(value: number): Duration;
13
15
  static Seconds(value: number): Duration;
14
16
  static Ms(value: number): Duration;
17
+ get weeks(): number;
15
18
  get days(): number;
16
19
  get hours(): number;
17
20
  get minutes(): number;
@@ -7,9 +7,13 @@ export class Duration {
7
7
  static MS_IN_MINUTE = 60 * Duration.MS_IN_SECOND;
8
8
  static MS_IN_HOUR = 60 * Duration.MS_IN_MINUTE;
9
9
  static MS_IN_DAY = 24 * Duration.MS_IN_HOUR;
10
+ static MS_IN_WEEK = 7 * Duration.MS_IN_DAY;
10
11
  constructor(candidateMs) {
11
12
  this.internal = DurationMs.parse(candidateMs);
12
13
  }
14
+ static Weeks(value) {
15
+ return new Duration(value * Duration.MS_IN_WEEK);
16
+ }
13
17
  static Days(value) {
14
18
  return new Duration(value * Duration.MS_IN_DAY);
15
19
  }
@@ -25,6 +29,9 @@ export class Duration {
25
29
  static Ms(value) {
26
30
  return new Duration(value);
27
31
  }
32
+ get weeks() {
33
+ return Duration.rounding.round(this.internal / Duration.MS_IN_WEEK);
34
+ }
28
35
  get days() {
29
36
  return Duration.rounding.round(this.internal / Duration.MS_IN_DAY);
30
37
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bgord/tools",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Bartosz Gordon",
@@ -21,7 +21,7 @@
21
21
  "preinstall": "bunx only-allow bun"
22
22
  },
23
23
  "devDependencies": {
24
- "@biomejs/biome": "2.3.0",
24
+ "@biomejs/biome": "2.3.1",
25
25
  "@commitlint/cli": "20.1.0",
26
26
  "@commitlint/config-conventional": "20.0.0",
27
27
  "@types/bun": "1.3.1",
@@ -10,11 +10,16 @@ export class Duration {
10
10
  private static readonly MS_IN_MINUTE = 60 * Duration.MS_IN_SECOND;
11
11
  private static readonly MS_IN_HOUR = 60 * Duration.MS_IN_MINUTE;
12
12
  private static readonly MS_IN_DAY = 24 * Duration.MS_IN_HOUR;
13
+ private static readonly MS_IN_WEEK = 7 * Duration.MS_IN_DAY;
13
14
 
14
15
  private constructor(candidateMs: number) {
15
16
  this.internal = DurationMs.parse(candidateMs);
16
17
  }
17
18
 
19
+ static Weeks(value: number): Duration {
20
+ return new Duration(value * Duration.MS_IN_WEEK);
21
+ }
22
+
18
23
  static Days(value: number): Duration {
19
24
  return new Duration(value * Duration.MS_IN_DAY);
20
25
  }
@@ -31,6 +36,10 @@ export class Duration {
31
36
  return new Duration(value);
32
37
  }
33
38
 
39
+ get weeks(): number {
40
+ return Duration.rounding.round(this.internal / Duration.MS_IN_WEEK);
41
+ }
42
+
34
43
  get days(): number {
35
44
  return Duration.rounding.round(this.internal / Duration.MS_IN_DAY);
36
45
  }