[time-nuts] small multi-timezone display

Didier Juges shalimr9 at gmail.com
Sun Jan 10 05:27:46 UTC 2021


Well, the latency in the php web page I posted earlier bugged the heck out
of me so I redid it the "right" way:

http://www.ko4bb.com/js/clock/?tz=America/Los_Angeles,Europe/Paris,Asia/Novosibirsk

Now the web page loads a Javascript program that uses the local machine's
time, the internet is only involved when loading the page initially, saving
many many electrons!
If you keep the local machine clock in sync with any of the many ntp or
sntp apps, the time will be correct (but not necessarily exactly on the
second, that will be for the next version...)

Here also you can have as many time zones as you want, just add them on the
command line with a comma separator.
Time zone definitions can be found on the Wikipedia page:
https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

Didier KO4BB

PS: the code (it uses the luxon javascript library):

<!DOCTYPE html "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>World Clock</title>
<script type="text/javascript" src="luxon.js"></script>
<script>
var DateTime = luxon.DateTime;
var out_str="";
function getParameterByName( name, url = window.location.href ){
  name = name.replace( /[\[\]]/g, '\\$&' );
  var regex = new RegExp( '[?&]' + name + '(=([^&#]*)|&|#|$)' ),
  results = regex.exec( url );
  if( !results) return null;
  if( !results[2] ) return '';
  return decodeURIComponent( results[2].replace(
    /\+/g, ' ' ));
}
function load(){
  setInterval( function(){ putAllTimes();}, 1000 );
}
function putAllTimes(){
  DateTime = luxon.DateTime;
  var tzs = getParameterByName( 'tz' );
  var tza = tzs.split(",")
  tza.forEach( putOneTime );
  document.getElementById( 'time' ).innerHTML = out_str;
}
function putOneTime( tz, index ){
  var ttime = DateTime.fromObject({zone: tz});
  if( index == 0 )
    out_str = tz + ": " +
    ttime.toLocaleString(DateTime.DATETIME_MED_WITH_SECONDS) + "<p>";
  else
    out_str += tz + ": " +
    ttime.toLocaleString(DateTime.DATETIME_MED_WITH_SECONDS) + "<p>";
}
</script>
</head>
<body onload="load()">
<h2>KO4BB's World Clock</h2>
<div id="time">
</div>
</body></html>



On Sat, Jan 9, 2021 at 5:23 PM Mark Spencer <mark at alignedsolutions.com>
wrote:

> This thread prompted me to turn on my old IPad1 and I confirmed the
> Emerald Time app I downloaded many years ago is still functional.
>
>
> Mark Spencer
> mark at alignedsolutions.com
> 604 762 4099
>
> > On Jan 8, 2021, at 12:16 PM, paul swed <paulswedb at gmail.com> wrote:
> >
> > Old iphones maybe cheap or you may have one. Since LTE4 I guess is in the
> > process of being turned off old iphone 5s will no longer work.
> > My wife now has a iphone 6 and I have ordered a battery for the 5 because
> > it is a useful widget that looks good and can use wi-fi.
> > Granted thats a small screen and thats why earlier I was suggesting one
> of
> > the larger nice tablets. I have an Asus tablet driving a 27" screen 24 X
> 7.
> > I am actually looking at clock programs to load onto the asus. Just
> started
> > looking last week.
> > Regards
> > Paul
> > WB8TSL
> >
> >> On Fri, Jan 8, 2021 at 2:50 PM John Sloan <jsloan at diag.com> wrote:
> >>
> >> I’d investigate whether there was an Android “World Clock” app whose
> >> display had your requirements, then buy an Android tablet in your price
> >> range and with the appropriate form factor. (I like the “World Clock”
> app
> >> on my iPhone, but I’ve never encountered a cheap iPhone.)
> >>
> >> --
> >> J. L. Sloan            Digital Aggregates Corp.
> >> +1 303 940 9064 (O)    3440 Youngfield St. #209
> >> +1 303 489 5178 (M)    Wheat Ridge CO 80033 USA
> >> jsloan at diag.com        http://www.diag.com <http://www.diag.com/>
> >>
> >>> On Jan 8, 2021, at 8:29 , time-nuts-request at lists.febo.com wrote:
> >>>
> >>> [time-nuts] small multi-timezone display
> >>
> >> _______________________________________________
> >> time-nuts mailing list -- time-nuts at lists.febo.com
> >> To unsubscribe, go to
> >> http://lists.febo.com/mailman/listinfo/time-nuts_lists.febo.com
> >> and follow the instructions there.
> > _______________________________________________
> > time-nuts mailing list -- time-nuts at lists.febo.com
> > To unsubscribe, go to
> http://lists.febo.com/mailman/listinfo/time-nuts_lists.febo.com
> > and follow the instructions there.
>
> _______________________________________________
> time-nuts mailing list -- time-nuts at lists.febo.com
> To unsubscribe, go to
> http://lists.febo.com/mailman/listinfo/time-nuts_lists.febo.com
> and follow the instructions there.
>



More information about the Time-nuts_lists.febo.com mailing list