[FIX] several bugs at the time calculations fixes by rewriting them
This commit is contained in:
parent
492674393f
commit
8f470e37ef
3 changed files with 162 additions and 45 deletions
78
tests.php
Normal file
78
tests.php
Normal file
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
// -------------------------------------------
|
||||
// outdoor lights control -- server
|
||||
// -- Manual "Unit Tests" --
|
||||
// copyright: Jannik Beyerstedt | https://jannikbeyerstedt.de
|
||||
// license: http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 License
|
||||
// -------------------------------------------
|
||||
|
||||
include "functions.php";
|
||||
|
||||
$light = new LightStatus();
|
||||
$light->update();
|
||||
|
||||
$testTimes = ["09:00",
|
||||
"11:00",
|
||||
"15:00",
|
||||
"20:00",
|
||||
"23:55",
|
||||
"00:05 +1day",
|
||||
"05:00 +1day",
|
||||
"06:00 +1day",
|
||||
"07:00 +1day",
|
||||
"09:00 +1day",
|
||||
"11:00 +1day",];
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<meta name="format-detection" content="telephone=no">
|
||||
<title>Lightscontrol Manual Tests</title>
|
||||
<meta name="robots" content="noindex, nofollow">
|
||||
|
||||
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="style.css?v1.1">
|
||||
</head>
|
||||
<body class="container">
|
||||
Standard Metrics:
|
||||
<table>
|
||||
<tr>
|
||||
<td>Sonnenaufgang:</td><td><?php echo $light->sunrise ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Sonnenuntergang:</td><td><?php echo $light->sunset ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Aktuelle Zeit:</td><td><?php echo date("H:i, Y-m-d",time()) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Nacht (ja/nein):</td><td><?php echo ($light->isNight) ? "ja" : "nein" ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
Test Sequences:
|
||||
<table>
|
||||
<tr>
|
||||
<td>now:</td>
|
||||
<td>Night: <?php echo ($light->isNight)?"1":"0" ?>, State: <?php echo ($light->state)?"1":"0" ?>,
|
||||
Change: <?php echo $light->changeTime ?> (<?php echo (int)($light->changeTime/60) ?>:<?php echo $light->changeTime%60 ?>h),
|
||||
API: <?php echo $light ?></td>
|
||||
</tr>
|
||||
<?php foreach ($testTimes as $t): ?>
|
||||
<tr><?php $light->update(strtotime($t));?>
|
||||
<td><?php echo $t ?>:</td>
|
||||
<td>Night: <?php echo ($light->isNight)?"1":"0" ?>, State: <?php echo ($light->state)?"1":"0" ?>,
|
||||
Change: <?php echo $light->changeTime ?> (<?php echo (int)($light->changeTime/60) ?>:<?php echo $light->changeTime%60 ?>h),
|
||||
API: <?php echo $light ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
|
||||
Config Array:
|
||||
<pre><?php echo var_dump($light->times) ?></pre>
|
||||
</body>
|
||||
|
||||
|
Reference in a new issue