Yes there’s databases like https://en.wikipedia.org/wiki/Tz_database that track this and that are included in libraries that do the arithmetics. It’s why those libraries are often relatively bulky.