Skip to content

Commit 39bff54

Browse files
committed
fix value mapping for input with type=time
1 parent bd50ec5 commit 39bff54

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

datex-bindings/dom-utils.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,13 @@ export class DOMUtils {
926926
return date.toISOString().slice(0,10)
927927
}
928928
else if (element.type == "time") {
929+
// empty value
930+
if (!val) return "";
931+
932+
// if already in time (e.g. HH:mm:ss) format, return directly
933+
if (typeof val == "string" && val.match(/^\d{2}:\d{2}(:\d{2}(\.\d{1,3})?)?$/)) return val;
934+
935+
// handle conversion from Date or number
929936
const date = val instanceof Date ? val : new Date(val);
930937
// show seconds if step is < 60
931938
if (element.step && Number(element.step) < 60) return date.toISOString().slice(11,19)

0 commit comments

Comments
 (0)