forked from MapComplete/MapComplete
Fix public holiday picker, add some tests, see #902
This commit is contained in:
parent
1773f851d1
commit
f99685c47d
2 changed files with 29 additions and 3 deletions
|
@ -316,12 +316,21 @@ export class OH {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* OH.ParsePHRule("PH Off") // => {mode: "off"}
|
||||
* OH.ParsePHRule("PH OPEN") // => {mode: "open"}
|
||||
* OH.ParsePHRule("PH 10:00-12:00") // => {mode: " ", start: "10:00", end: "12:00"}
|
||||
* OH.ParsePHRule(undefined) // => null
|
||||
* OH.ParsePHRule(null) // => null
|
||||
* OH.ParsePHRule("some random string") // => null
|
||||
*/
|
||||
public static ParsePHRule(str: string): {
|
||||
mode: string,
|
||||
start?: string,
|
||||
end?: string
|
||||
} {
|
||||
if (str === undefined) {
|
||||
if (str === undefined || str === null) {
|
||||
return null
|
||||
}
|
||||
str = str.trim();
|
||||
|
@ -330,13 +339,13 @@ export class OH {
|
|||
}
|
||||
|
||||
str = str.trim();
|
||||
if (str === "PH off") {
|
||||
if (str.toLowerCase() === "ph off") {
|
||||
return {
|
||||
mode: "off"
|
||||
}
|
||||
}
|
||||
|
||||
if (str === "PH open") {
|
||||
if (str.toLowerCase() === "ph open") {
|
||||
return {
|
||||
mode: "open"
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue