You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Peter H. Jin c51ea88650 Merge branch 'master' of https://gitlab.com/PHJArea217/nginx-clock 2 months ago
priv add demo and time zone selector 3 years ago
.gitignore Add DST timezones, change appearance 2 years ago
.gitlab-ci.yml Initial IERS Bulletin reading code 3 years ago
DST.java Add DST timezones, change appearance 2 years ago
IERSBulletinReader.java Initial IERS Bulletin reading code 3 years ago
README.md Change server location, update copyright year 2 years ago
clock.css Update to new servers, support strict CSP policies 2 months ago
clock.js Merge branch 'master' of https://gitlab.com/PHJArea217/nginx-clock 2 months ago
cloud-function.js Fix DST next time display, color change 2 years ago
csp.js Update to new servers, support strict CSP policies 2 months ago
demo.js Update to new servers, support strict CSP policies 2 months ago
favicon.ico Add DST timezones, change appearance 2 years ago
iers.js Update to new servers, support strict CSP policies 2 months ago
index.html Update to new servers, support strict CSP policies 2 months ago
make_demo.sh Update to new servers, support strict CSP policies 2 months ago
nginx.conf Remove some ES6-isms, other optimizations 2 years ago
online-demo.md Use actual nginx webserver as backend 2 years ago
tzselector.js Update to new servers, support strict CSP policies 2 months ago

README.md

nginx-clock

Web clock for nginx, ideal for NTP servers.

This project was inspired by the USNO Master Clock and a number of other web clocks, such as

The clock displays time in local time, Coordinated Universal Time (UTC) and all half-hour time zone offsets from -12 to +14. Support for other time zones and daylight saving time is planned. UPDATE: Daylight saving time is now supported.

A live version of this web clock is available at https://webclock.peterjin.org. See this document for more information.

How to self-host

You will need a computer (VPS, physical computer, or something else) running the nginx web server.

  1. Copy the index.html, clock.js, tzselector.js, and iers.js files to anywhere in the webserver's file-serving location.
  2. Look for the location /_insvc/time block in the nginx.conf file here and copy the entire block to your nginx.conf in the server block.
  3. If you would like to use a different location instead of /_insvc/time, you can update the top of clock.js to do so.

To enable leap second warnings, compile and run IERSBulletinReader.java using Java 8 or later and write its output to a file named iers-bulcd.json located in the same directory as the index.html file.

In order for the clock to display Daylight Saving Time information, you will need to create a file called dst.js. Compile and run DST.java and write the program output to dst.js in the same directory as the index.html file.

Pre-built versions of both files are available at

Todo list

  • Time zone selector
  • Leap second warnings (via IERS bulletin parsing)
  • Use multiple endpoint requests and average them out
  • Daylight saving time/summer time in time zone selector

License (2-clause BSD)

Copyright 2018-2019 Peter H. Jin All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.