knadh / dns.toys

A DNS server that offers useful utilities and services over the DNS protocol. Weather, world time, unit conversion etc.
https://www.dns.toys
MIT License
2.49k stars 135 forks source link

Actually useful: IANA timezone database over DNS #18

Open orent opened 2 years ago

orent commented 2 years ago

Look up the current UTC offset, the next switching date/time and the UTC offset after the switch for a named time zone.

DNS is actually a very efficient way to distribute this small but important pieces of information. If this is done on a zone attached to a real TLD it could instruct recursive DNS servers to set a very long expiration time. It can also pass through many firewalls.

knadh commented 2 years ago

I'm a bit confused. Could you give an example query + responses?

bortzmeyer commented 2 years ago
% dig asia/jakarta.timezone @dns.toys
"UTC+7"

% dig nextswitch.europe/paris.timezone @dns.toys
"2022-10-02T02:00:00"

With short names:

% dig PST.timezone @dns.toys
"UTC+5"

(It is not an error: names of time zones are not unique and PST is Pakistan Standard Time but also possibly two other zones. That's why it is better to use long names.)

knadh commented 2 years ago

That would indeed be useful. I'll try and do it at some point, but in the meanwhile, if anyone's willing to send a PR, please do!

bortzmeyer commented 2 years ago

That would indeed be useful. I'll try and do it at some point

Note that parsing the IANA timezone database for things like the transitions is not an easy task. Certainly not a two-hour job.