Skip to content

Commit 9c63b81

Browse files
committed
added negative prevention + fixed time bug
1 parent e1fb7c7 commit 9c63b81

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

html/static/index/js/app.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ var main = function() {
8484
// Current Time
8585
var d2 = new Date();
8686
var currentTime = d2.getTime() + (d2.getTimezoneOffset() * 60000) - startTime;
87-
87+
8888
// Convert miliseconds
8989
var seconds = currentTime / 1000;
9090
var minutes = seconds / 60;
@@ -93,7 +93,18 @@ var main = function() {
9393
// Get within current limits
9494
seconds = Math.floor(seconds % 60);
9595
minutes = Math.floor(minutes % 60);
96-
hours = Math.floor(hours % 24);
96+
console.log(Math.floor(hours), " --", Math.floor(hours % 24));
97+
if (hours - 24 >= 0)
98+
hours = Math.floor(hours);
99+
else
100+
hours = Math.floor(hours % 24);
101+
102+
// Negative time protection
103+
if (hours < 0 || minutes < 0 || seconds < 0) {
104+
d = new Date();
105+
startTime = d.getTime() + d.getTimezoneOffset() * 60000;
106+
return;
107+
}
97108

98109
// No-Life protection
99110
if (hours >= 30) {

0 commit comments

Comments
 (0)