[tz] Beginner's help request

Matt Johnson mj1856 at hotmail.com
Mon Oct 16 18:42:07 UTC 2017

Hi Daniel,

One thing to keep in mind - the TZ database is prolific, and already has widespread adoption in many platforms, languages and libraries.  Sure, there are many cases where one might need to go back to the sources, but most of the time there's already work of others to leverage.

In the case of the NodeMCU platform, I suggest you start with the "TZ" LUA module, shown here:

You'll want to use current data files though, rather than the few that are given there.  You should be able to generate them with the zic compiler from this project (though getting it working on Windows is tricky) - or you can just gather them precompiled from any tzdata distribution on a Linux system.


From: tz-bounces at iana.org <tz-bounces at iana.org> on behalf of Daniel Ford <dfnojunk at gmail.com>
Sent: Saturday, October 14, 2017 5:45 AM
To: tz at iana.org
Subject: [tz] Beginner's help request

I'm looking to develop a 'world clock' that could be sold to anyone (with
Internet access via a Wi-Fi AP) anywhere in the world, that will display
their local time, taking into account DST if/when applicable.

Given that DST 'rules' can change at the whim of governments, my firmware
will need to annually look up 'current' DST rules from the web.  After much
searching, it seems that your TZ Database is the best supported such
reference for time zone rules.  But I'm having great difficulty working out
how I might access its mine of information...

(I'll understand if you don't have time to help out a beginner, and maybe
then you could refer me to a help site for TZ database applications.)

I'm a hardware engineer with some programming experience, particularly
assembler (various MCUs) and some C, but little or no experience in other
languages.  I'm developing this clock on an Arduino-like platform (NodeMCU,
which has in-built Wi-Fi).  My development tools run on a Win7Pro64 PC.

The tools that you kindly provide for your database appear to be geared
primarily towards Linux/Unix platforms, and I have no idea how I might
convert them for a NodeMCU!  I'm looking for some 'simple' way to access the
desired TZ/DST information, preferably using simple string searches.

For my application, all I'm interested in are the *current* rules.  The
wealth of history in your db is undoubtedly of interest to many, but for me
is just 'clutter' to be searched through.  But writing a program to find
those rules for a particular locality has me stumped right now.  I can't
expect my dumb users to know a letter code for their time-zone/DST-rules, so
all I'm expecting them to select from program-generated lists are: (1) their
world region (Europe, Asia, Australasia, etc), and (2) the name of a major
city in their time-zone with the same DST rules they follow.

Let's take a concrete example: say my user has nominated 'Australasia' and
'Hobart'.  So I look in your Australasia file and do a (manual at this
stage) search for 'Hobart', but find only one reference to it (other than in
comments).  The jumble of numbers and letters there do not (clearly) tell me
when DTS starts or ends.  So how could I possibly write some code to find
out that required information??

I've looked through the TZ_database-2017b.tar file for some sort of 'how-to'
explanation of what all the file contents mean and how to programmatically
search for a specific TZ, but have so far found nothing.

Ideally, what I'd like to see is a text-only table of just current TZ/DST
rules for each region/locality (they could all fit into a single file with
all the historical data and comments removed), perhaps in the clear form
used by Jack Christensen in his excellent Arduino Timezone library examples,
such as...

// Australia Eastern Time Zone (Sydney, Melbourne, Hobart)
TimeChangeRule aEDT = {"AEDT", First, Sun, Oct, 2, 660};
TimeChangeRule aEST = {"AEST", First, Sun, Apr, 3, 600};
TimezoneExt ausET("NSW, Vic, Tas", aEDT, aEST);
// Australia Eastern Time Zone (Brisbane)
TimezoneExt QldT("Queensland", aEST, aEST);  // no DST in Qld!

... which clearly tells me in a program-searchable way that in the main
eastern states DST starts on the first Sunday in October at 2am, becoming
UTC offset +11 hours (660 minutes), and ends on the first Sunday in April at
3am, reverting to UTC offset +10 hours.  Couldn't be simpler!

Any help in using the TZ database will be much appreciated (and acknowledged
in my source code).

Daniel Ford (Gerroa, Australia)
"My loathings are simple: stupidity, oppression, crime, cruelty, soft
music." - Vladimir Nabokov

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mm.icann.org/pipermail/tz/attachments/20171016/d568d29f/attachment.htm>

More information about the tz mailing list