Accept unix time for --start CLI option

This commit is contained in:
Alexander
2020-01-22 10:27:13 +13:00
parent 34c34603b6
commit e56cdf4ed3
3 changed files with 5 additions and 3 deletions

View File

@@ -119,7 +119,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.

View File

@@ -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'],

View File

@@ -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.';