@akc42/app-utils 5.0.15 → 5.0.16
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.
- package/date-utils.js +3 -3
- package/package.json +1 -1
package/date-utils.js
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
const timeRegex = /^((?:0?[0-9]|1[0-9]|2[0-3]))(?::((?:0?[0-9]|[1-5][0-9])))?$/;
|
|
21
21
|
export function minToTime(m) {
|
|
22
22
|
if (m === 0) return '00:00';
|
|
23
|
-
if (isNaN(m) || m < 0 || m > 1439) return
|
|
23
|
+
if (isNaN(m) || m < 0 || m > 1439) return false;
|
|
24
24
|
|
|
25
25
|
var hr = Math.floor(m/60);
|
|
26
26
|
var mn = Math.floor(m % 60);
|
|
@@ -28,7 +28,7 @@ export function minToTime(m) {
|
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
export function timeToMin(time) {
|
|
31
|
-
if (typeof time !== 'string') return
|
|
31
|
+
if (typeof time !== 'string') return 0; //protective against crashes
|
|
32
32
|
if (time.length === 0) return -1;
|
|
33
33
|
const matches = timeRegex.exec(time);
|
|
34
34
|
if (matches) {
|
|
@@ -37,7 +37,7 @@ export function timeToMin(time) {
|
|
|
37
37
|
let hours = parseInt(matches[1], 10);
|
|
38
38
|
if (Number.isInteger(hours) && Number.isInteger(mins)) return (hours * 60) + mins;
|
|
39
39
|
}
|
|
40
|
-
return
|
|
40
|
+
return 0;
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
const urlRegex = /^((?:19|2[01])(?:(?:(?:0[48]|[2468][048]|[13579][26])(?=-02-29))|\d{2}(?!-02-(?:29|3[01]))))-((?:02(?!-3[01])|0[469](?!-31)|11(?!-31)|(?:0[13578]|1[02])))-([0][1-9]|[12][0-9]|3[01])$/;
|