Make date formatting and parsing re-entrant and libc independent.

localtime is not re-entrant, and doesn't work with negative (pre-1970)
time stamps on windows. Replace with our own simplified variant.

Parse date string format manually rather than using scanf.
Only accept ISO 8601 format.