From 03af1fed48370ddc4772709207f064c16191f5c1 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sat, 25 Jun 2016 13:21:33 +0200 Subject: add clock.now() diff --git a/www/js/clock.js b/www/js/clock.js index 3562b1e..458d1c7 100644 --- a/www/js/clock.js +++ b/www/js/clock.js @@ -32,8 +32,16 @@ function Clock() { this.clock_rtt = 0; this.state = 'NEW'; + this.getRDTimeMS = function() { + return (+new Date()) + (this.last_message.tz_offset * 1000) + this.clock_offset; + } + + this.now = function() { + return new Date(this.getRDTimeMS()); + } + this.redraw = function() { - var rdtime_ms = (+new Date()) + (this.last_message.tz_offset * 1000) + this.clock_offset; + var rdtime_ms = this.getRDTimeMS(); var rdtime = new Date(rdtime_ms); var date_str = weekday_short[rdtime.getUTCDay()] + ', '; -- cgit v0.10.2