Parse empty string (TimeInputParser)

This commit is contained in:
manubo
2019-09-30 17:13:11 +02:00
parent ed2628528b
commit bf3010cbc1

View File

@@ -2,11 +2,13 @@ export default class TimeInputParser {
#input #input
constructor(input) { constructor(input) {
this.#input = input.toLowerCase().replace(/[\s()]/g, "") this.#input = (input ?? "").toLowerCase().replace(/[\s()]/g, "")
} }
parseSeconds() { parseSeconds() {
if (this.#isDecimal()) { if (this.#input === "") {
return 0
} else if (this.#isDecimal()) {
return Math.round(parseFloat(this.#parseDecimal()) * 3600) return Math.round(parseFloat(this.#parseDecimal()) * 3600)
} else if (this.#isTime()) { } else if (this.#isTime()) {
return this.#parseTimeAsSeconds() return this.#parseTimeAsSeconds()