forked from Cliffbreak/Time-Service
refactored clock
This commit is contained in:
parent
38c66af1a2
commit
84417580d2
1 changed files with 14 additions and 12 deletions
|
@ -1,28 +1,30 @@
|
||||||
var offset = 49020000;
|
const offset = 49020000;
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
// Create two variable with the names of the months and days in an array
|
// Create two variable with the names of the months and days in an array
|
||||||
var monthNames = [ "Januar" , "Febuar" , "M<EFBFBD>rz" , "April" , "Mai" , "Juni" , "Juli" , "August" , "September" , "Oktober" , "November" , "Dezember" ];
|
var monthNames = [ "Januar" , "Febuar" , "März" , "April" , "Mai" , "Juni" , "Juli" , "August" , "September" , "Oktober" , "November" , "Dezember" ];
|
||||||
var dayNames= [ "Sonntag" , "Montag" , "Dienstag" , "Mittwoch" , "Donnerstag" , "Freitag" , "Samstag" ];
|
var dayNames= [ "Sonntag" , "Montag" , "Dienstag" , "Mittwoch" , "Donnerstag" , "Freitag" , "Samstag" ];
|
||||||
|
|
||||||
timeTick();
|
timeTick();
|
||||||
setInterval(timeTick, 1000);
|
setInterval(timeTick, 1000);
|
||||||
|
|
||||||
|
function twoDigits (n) {
|
||||||
|
return (n < 10 ? '0': '') + n;
|
||||||
|
}
|
||||||
|
|
||||||
function timeTick() {
|
function timeTick() {
|
||||||
$('.point').css('animation-name', 'none');
|
$('.point').css('animation-name', 'none');
|
||||||
var date = new Date();
|
const date = new Date();
|
||||||
date.setTime(date.getTime() - offset);
|
date.setTime(date.getTime() - offset);
|
||||||
|
|
||||||
var seconds = date.getSeconds();
|
const seconds = date.getSeconds();
|
||||||
var minutes = date.getMinutes();
|
const minutes = date.getMinutes();
|
||||||
var hours = date.getHours();
|
const hours = date.getHours();
|
||||||
|
|
||||||
|
$('#date').html(dayNames[date.getDay()] + " " + date.getDate() + ' ' + monthNames[2] + ' ' + date.getFullYear());
|
||||||
$('#date').html(dayNames[date.getDay()] + " " + date.getDate() + ' ' + monthNames[date.getMonth()] + ' ' + date.getFullYear());
|
$("#sec").html(twoDigits(seconds));
|
||||||
$("#sec").html(( seconds < 10 ? "0" : "" ) + seconds);
|
$("#min").html(twoDigits(minutes));
|
||||||
$("#min").html(( minutes < 10 ? "0" : "" ) + minutes);
|
$("#hours").html(twoDigits(hours));
|
||||||
$("#hours").html(( hours < 10 ? "0" : "" ) + hours);
|
|
||||||
|
|
||||||
$('.point').css('animation-name', 'flash');
|
$('.point').css('animation-name', 'flash');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue