Guard against null return value from localtime()