Greatly simplify things by using format-time-string.