From 22b38c2838ce799cd448db2c5a94af5023323b3f Mon Sep 17 00:00:00 2001 From: Brendan Heywood Date: Thu, 26 Mar 2020 00:56:17 +1100 Subject: [PATCH] Accept natural language start times #163 --- edit.php | 3 +++ lang/en/auth_outage.php | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/edit.php b/edit.php index d707989..bbc6ad8 100644 --- a/edit.php +++ b/edit.php @@ -65,6 +65,9 @@ if ($clone) { $default = $config->default_time; if ($default) { + // First try natural language parsing. + $time = strtotime($default); + // Lean on the Task API to convert the cron syntax to // the next valid outage date and time. $parts = explode(' ', $default); diff --git a/lang/en/auth_outage.php b/lang/en/auth_outage.php index 3ea661e..ae585aa 100644 --- a/lang/en/auth_outage.php +++ b/lang/en/auth_outage.php @@ -81,7 +81,10 @@ $string['defaultoutagedurationdescription'] = 'Default duration (in minutes) of $string['defaultwarningduration'] = 'Warning duration'; $string['defaultwarningdurationdescription'] = 'Default warning time (in minutes) for outages.'; $string['defaulttime'] = 'Default time'; -$string['defaulttimedescription'] = 'The default time for the next outage. This is expressed in cron notation, eg to say that a regular outage window is any thursday at 7pm you would set this to:
0 19 * * 4
'; +$string['defaulttimedescription'] = 'The default time for the next outage. This is expressed in either natural language or a cron notation. eg to say that a regular outage window is any Thursday at 7pm either of these work: +
0 19 * * 4
+next Thursday 7pm
+See also Cron expressions and Relative dates'; $string['defaulttitle'] = 'Title'; $string['defaulttitledescription'] = 'Default title for outages. Use {{start}} and {{stop}} placeholders as required.'; $string['defaulttitlevalue'] = 'System down from {{start}} for {{duration}}';