Added most of the code needed for dealing with dates.