@cityssm/utils-datetime 1.4.0 → 1.4.1
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
const timeStringRegex = /^[01]\d:[0-5]\d
|
|
1
|
+
const timeStringRegex = /^[01]\d:[0-5]\d$/v;
|
|
2
|
+
const timeStringRegex2 = /^2[0-3]:[0-5]\d$/v;
|
|
2
3
|
/**
|
|
3
4
|
* Determines if a string is a valid time string.
|
|
4
5
|
* @param possibleTimeString - A possible time string.
|
|
@@ -6,6 +7,7 @@ const timeStringRegex = /^[01]\d:[0-5]\d$/;
|
|
|
6
7
|
*/
|
|
7
8
|
export function isValidTimeString(possibleTimeString) {
|
|
8
9
|
return (typeof possibleTimeString === 'string' &&
|
|
9
|
-
|
|
10
|
-
timeStringRegex.test(possibleTimeString)
|
|
10
|
+
possibleTimeString.length === 5 &&
|
|
11
|
+
(timeStringRegex.test(possibleTimeString) ||
|
|
12
|
+
timeStringRegex2.test(possibleTimeString)));
|
|
11
13
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { TimeString } from '../types.js'
|
|
2
2
|
|
|
3
|
-
const timeStringRegex = /^[01]\d:[0-5]\d$/
|
|
3
|
+
const timeStringRegex = /^[01]\d:[0-5]\d$/v
|
|
4
|
+
const timeStringRegex2 = /^2[0-3]:[0-5]\d$/v
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Determines if a string is a valid time string.
|
|
@@ -12,7 +13,8 @@ export function isValidTimeString(
|
|
|
12
13
|
): possibleTimeString is TimeString {
|
|
13
14
|
return (
|
|
14
15
|
typeof possibleTimeString === 'string' &&
|
|
15
|
-
|
|
16
|
-
timeStringRegex.test(possibleTimeString)
|
|
16
|
+
possibleTimeString.length === 5 &&
|
|
17
|
+
(timeStringRegex.test(possibleTimeString) ||
|
|
18
|
+
timeStringRegex2.test(possibleTimeString))
|
|
17
19
|
)
|
|
18
20
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityssm/utils-datetime",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "Date time utilities for Node.js applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"date",
|
|
@@ -35,8 +35,11 @@
|
|
|
35
35
|
"test": "node --test \"test/test.js\""
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@types/node": "^26.
|
|
39
|
-
"eslint-config-cityssm": "^
|
|
40
|
-
"prettier-config-cityssm": "^2.
|
|
38
|
+
"@types/node": "^26.6.5",
|
|
39
|
+
"eslint-config-cityssm": "^58.0.0",
|
|
40
|
+
"prettier-config-cityssm": "^2.2.0"
|
|
41
|
+
},
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=20"
|
|
41
44
|
}
|
|
42
45
|
}
|