Added regex check when writing to catch wrongly formatted dates.