[tz] Beginner's help request

Daniel Ford dfnojunk at gmail.com
Tue Oct 31 00:30:51 UTC 2017


G'day guys.  Sorry for the long absence - had a quest staying over a week, which interrupted my hobby project!

After lots of reading of various mentioned info files, I think I have a little understanding of the structure of the TZdb now, and how I might make use of it to update the DST rules in my proposed clock.  Would you please look over the description below and tell me if I've got it right, or otherwise!

-----
Possible method...

User selects:
	First: region, from presented list.
	Then program displays list of cities within that region, and user picks one.
We then have a region/city string, e.g. 'Africa/Casablanca'.
Then we need to download the current 'africa' file (for the above example) from the TZ FTP page, and save it in SPIFFS.
We then do a string search in that file, for (in this example) "Zone Africa/Casablanca" (where the space between Zone and Africa can be *any* whitespace, though typically a tab character).
Move forward through the file, line by line, till you find the last line of that zone entry (it's UNTIL column is empty, [and maybe it's always followed by an empty line?]).
Note the GMTOFF and name of the rule.
Now move backwards through the file, line by line, till you find a Rule line with that name, having:
		a FROM date* <= the current date, AND
		a TO date* >= the current date, OR
			'max', OR
			'-' or 'only' iff FROM == current date
		(* 'date' will often be just a year, in which case the comparison is with the current year)
	For each such line, store the IN, ON, AT and SAVE values.
	When sequenced in date order, these become the current DST rules for this reference city.
If no Rule line meets these criteria, take GMTOFF to be the offset throughout the year.
-----

Also, if anyone's interested, I have posted a simple demo of some of the hardware that will be used in my clock (the NodeMCU in particular).  I won't be using the display in that video (way too small), and of course I need to add the TZdb stuff to my code, so DST rules are continually updated, rather than hard-coded as in that demo.  And my proposed clock will only display accurate local time, not multiple zones.
https://youtu.be/PyDerVMuXDI

Regards,
Daniel
---------------
Daniel Ford (Gerroa, Australia)



More information about the tz mailing list