From a3532a41daa6be4f70ad3bf7d1365041afc54e14 Mon Sep 17 00:00:00 2001 From: Michael <35783820+mib1185@users.noreply.github.com> Date: Mon, 9 Oct 2023 14:36:16 +0200 Subject: [PATCH] Add before offset to sun condition description (#18152) --- src/data/automation_i18n.ts | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/data/automation_i18n.ts b/src/data/automation_i18n.ts index 8d91721ed4..90da6e56ef 100644 --- a/src/data/automation_i18n.ts +++ b/src/data/automation_i18n.ts @@ -955,23 +955,43 @@ const tryDescribeCondition = ( base += " sun"; if (condition.after) { - let duration = ""; + let after_duration = ""; if (condition.after_offset) { 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") { - duration = ` offset by ${condition.after_offset}`; + after_duration = ` offset by ${condition.after_offset}`; } 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) { - 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;