From 1d1fb941429dd2f49801077379aaaa25d14b255f Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 22 Jan 2020 10:27:13 +1300 Subject: [PATCH] Accept unix time for --start CLI option --- README.md | 2 +- classes/local/cli/create.php | 4 +++- lang/en/auth_outage.php | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0e0887d..707467f 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ Creates a new outage. -c, --clone clone another outage except for the start time. -a, --autostart must be Y or N, sets if the outage automatically triggers maintenance mode. -w, --warn how many seconds before it starts to display a warning. - -s, --start in how many seconds should this outage start. Required. + -s, --start in how many seconds should this outage start or unix time to start outage. Required. -d, --duration how many seconds should the outage last. -t, --title the title of the outage. -e, --description the description of the outage. diff --git a/classes/local/cli/create.php b/classes/local/cli/create.php index 2be46bf..bdd04f5 100644 --- a/classes/local/cli/create.php +++ b/classes/local/cli/create.php @@ -170,7 +170,9 @@ class create extends clibase { $this->become_admin_user(); // Create the outage. - $start = $this->time + $options['start']; + // If time is above 1500000000 then it must be a unix time timestamp, otherwise they are trying to create + // an outage 47 years in advance. + $start = $options['start'] > 1500000000 ? $options['start'] : $this->time + $options['start']; $outage = new outage([ 'autostart' => $options['autostart'], 'warntime' => $start - $options['warn'], diff --git a/lang/en/auth_outage.php b/lang/en/auth_outage.php index fa167c5..cdce192 100644 --- a/lang/en/auth_outage.php +++ b/lang/en/auth_outage.php @@ -34,7 +34,7 @@ $string['clicreateparamdescription'] = 'the description of the outage.'; $string['clicreateparamduration'] = 'how many seconds should the outage last.'; $string['clicreateparamhelp'] = 'shows parameters help.'; $string['clicreateparamonlyid'] = 'only outputs the new outage id, useful for scripts.'; -$string['clicreateparamstart'] = 'in how many seconds should this outage start. Required.'; +$string['clicreateparamstart'] = 'in how many seconds should this outage start or unix time to start outage. Required.'; $string['clicreateparamtitle'] = 'the title of the outage.'; $string['clicreateparamwarn'] = 'how many seconds before it starts to display a warning.'; $string['clifinishhelp'] = 'Finishes an ongoing outage.';