diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2023-11-28 10:12:50 +0100 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2023-11-28 10:12:58 +0100 |
commit | b474771b890a5addca483260a674119563eb2227 (patch) | |
tree | 954bfc14f77d8ec8cb855e94422ee8b45563c189 /html | |
parent | test/host: show the latest log lines (diff) | |
download | wg-api-web-b474771b890a5addca483260a674119563eb2227.tar.gz wg-api-web-b474771b890a5addca483260a674119563eb2227.zip |
account for small time driftsv1.1.5
Diffstat (limited to 'html')
-rw-r--r-- | html/index.html | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/html/index.html b/html/index.html index 7ac4100..a78efbc 100644 --- a/html/index.html +++ b/html/index.html @@ -106,11 +106,17 @@ const MSECS_IN_DAY = 24 * MSECS_IN_HOUR; function date_to_readable(date) { const now = Date.now(); - if (Date.now() < date) { - return 'future???'; + let duration = now - date; + + if (Math.abs(duration) < 2 * MSECS_IN_SEC) { + // Most likely, the time is not synchronized either on the server or + // the client. + return 'now'; } - let duration = now - date; + if (duration < 0) { + return 'future???'; + } let days = Math.floor(duration / MSECS_IN_DAY); duration -= days * MSECS_IN_DAY; |