@tmlmobilidade/types 20260615.1002.3 → 20260615.1034.33

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.
@@ -4,7 +4,7 @@ import { z } from 'zod';
4
4
  *
5
5
  * Rules:
6
6
  * - minimum is 04:00
7
- * - no upper hour limit
7
+ * - maximum is 29:59
8
8
  * - minutes must be 00–59
9
9
  * - hour must be at least 2 digits in stored format
10
10
  */
@@ -17,10 +17,8 @@ export declare function operationalHhmmToMinutes(hhmm: string, ignoreStartHour?:
17
17
  * - "0800" -> "08:00"
18
18
  * - "2200" -> "22:00"
19
19
  * - "2600" -> "26:00"
20
- * - "10000" -> "100:00"
21
20
  * - "8:00" -> "08:00"
22
21
  * - "26:00" -> "26:00"
23
- * - "100:00" -> "100:00"
24
22
  *
25
23
  * Returns null if it cannot normalize safely.
26
24
  */
@@ -2,12 +2,13 @@
2
2
  import { z } from 'zod';
3
3
  /* * */
4
4
  const OPERATIONAL_DAY_START_HOUR = 4;
5
+ const OPERATIONAL_DAY_END_HOUR = 29;
5
6
  /**
6
7
  * Parses an operational HH:MM.
7
8
  *
8
9
  * Rules:
9
10
  * - minimum is 04:00
10
- * - no upper hour limit
11
+ * - maximum is 29:59
11
12
  * - minutes must be 00–59
12
13
  * - hour must be at least 2 digits in stored format
13
14
  */
@@ -29,6 +30,10 @@ export function operationalHhmmToMinutes(hhmm, ignoreStartHour = false) {
29
30
  if (!ignoreStartHour && total < minAllowed) {
30
31
  throw new Error(`Operational time out of range: ${hhmm}`);
31
32
  }
33
+ const maxAllowed = (OPERATIONAL_DAY_END_HOUR * 60) + 59; // 29:59
34
+ if (!ignoreStartHour && total > maxAllowed) {
35
+ throw new Error(`Operational time out of range: ${hhmm}`);
36
+ }
32
37
  return total;
33
38
  }
34
39
  /**
@@ -39,10 +44,8 @@ export function operationalHhmmToMinutes(hhmm, ignoreStartHour = false) {
39
44
  * - "0800" -> "08:00"
40
45
  * - "2200" -> "22:00"
41
46
  * - "2600" -> "26:00"
42
- * - "10000" -> "100:00"
43
47
  * - "8:00" -> "08:00"
44
48
  * - "26:00" -> "26:00"
45
- * - "100:00" -> "100:00"
46
49
  *
47
50
  * Returns null if it cannot normalize safely.
48
51
  */
@@ -75,7 +78,7 @@ export const HHMMSchema = z
75
78
  console.warn('Invalid HHMM:', value, err);
76
79
  return false;
77
80
  }
78
- }, 'Invalid operational time (expected HH:MM with minimum 04:00)')
81
+ }, 'Invalid operational time (expected HH:MM between 04:00 and 29:59)')
79
82
  .brand();
80
83
  /**
81
84
  * Runtime-safe creator (validates + brands)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmlmobilidade/types",
3
- "version": "20260615.1002.3",
3
+ "version": "20260615.1034.33",
4
4
  "author": {
5
5
  "email": "iso@tmlmobilidade.pt",
6
6
  "name": "TML-ISO"