Add before offset to sun condition description (#18152)

This commit is contained in:
Michael 2023-10-09 14:36:16 +02:00 committed by GitHub
parent ae35fd1eb8
commit a3532a41da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -955,23 +955,43 @@ const tryDescribeCondition = (
base += " sun"; base += " sun";
if (condition.after) { if (condition.after) {
let duration = ""; let after_duration = "";
if (condition.after_offset) { if (condition.after_offset) {
if (typeof condition.after_offset === "number") { if (typeof condition.after_offset === "number") {
duration = ` offset by ${secondsToDuration(condition.after_offset)!}`; after_duration = ` offset by ${secondsToDuration(
condition.after_offset
)!}`;
} else if (typeof condition.after_offset === "string") { } else if (typeof condition.after_offset === "string") {
duration = ` offset by ${condition.after_offset}`; after_duration = ` offset by ${condition.after_offset}`;
} else { } else {
duration = ` offset by ${JSON.stringify(condition.after_offset)}`; after_duration = ` offset by ${JSON.stringify(
condition.after_offset
)}`;
} }
} }
base += ` after ${condition.after}${duration}`; base += ` after ${condition.after}${after_duration}`;
} }
if (condition.before) { if (condition.before) {
base += ` before ${condition.before}`; let before_duration = "";
if (condition.before_offset) {
if (typeof condition.before_offset === "number") {
before_duration = ` offset by ${secondsToDuration(
condition.before_offset
)!}`;
} else if (typeof condition.before_offset === "string") {
before_duration = ` offset by ${condition.before_offset}`;
} else {
before_duration = ` offset by ${JSON.stringify(
condition.before_offset
)}`;
}
}
base += ` before ${condition.before}${before_duration}`;
} }
return base; return base;