core: don't crash on strange timezones.

(cherry picked from commit 5b2ae2f63fa0ecde16727d10c75b60c351eeb8cb)