[FIX] correct remaining time calculation at night before midnight, set body max-width

This commit is contained in:
Jannik Beyerstedt 2017-08-02 22:58:44 +02:00
parent 85f3ee44ca
commit b0a675ab3d
3 changed files with 20 additions and 6 deletions

View file

@ -70,10 +70,10 @@ class LightStatus {
$startTime = strtotime($this->times[$timeKey]['on']); $startTime = strtotime($this->times[$timeKey]['on']);
$stopTime = strtotime($this->times[$timeKey]['off']); $stopTime = strtotime($this->times[$timeKey]['off']);
if ($stopTime < $startTime) { if ($stopTime < $startTime) {
$stopTime += (24 * 60 * 60); $stopTime += (24*60*60);
if (($stopTime - $currentTime) > (24 * 60 * 60)) { if (($stopTime - $currentTime) > (24*60*60)) {
$startTime -= (24 * 60 * 60); $startTime -= (24*60*60);
$stopTime -= (24 * 60 * 60); $stopTime -= (24*60*60);
} }
} }
@ -82,6 +82,16 @@ class LightStatus {
$this->changeTime = (int)(($stopTime - $currentTime) / 60); $this->changeTime = (int)(($stopTime - $currentTime) / 60);
$this->waitTime = 1; $this->waitTime = 1;
return true; return true;
} elseif ($currentTime < $startTime || ($startTime+(24*60*60) - $currentTime) < (12*60*60) ) {
// right before the next time interval
$this->state = false;
if ($currentTime < $startTime) {
$this->changeTime = (int)( ($startTime - $currentTime) / 60 );
} else {
$this->changeTime = (int)( (($startTime+(24*60*60)) - $currentTime) / 60 );
}
$this->waitTime = 1;
return true;
} }
} }

View file

@ -69,8 +69,8 @@ if (isset($_GET['action'])) {
<link rel="stylesheet" href="style.css"> <link rel="stylesheet" href="style.css">
</head> </head>
<body class="container-fluid"> <body class="container">
<h1>Außenbeleuchtung</h1> <h1>Garagenlicht</h1>
<?php if ($error_string != '') : ?> <?php if ($error_string != '') : ?>
<div class="alert alert-danger" role="alert"><?php echo $error_string ?></div> <div class="alert alert-danger" role="alert"><?php echo $error_string ?></div>

View file

@ -3,6 +3,10 @@
* license: http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 License * license: http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 License
*/ */
body {
max-width: 500px;
}
form div.form-group > div > input.form-control { form div.form-group > div > input.form-control {
display: inline-block; display: inline-block;
width: 49%; width: 49%;