October 2006
Intermediate to advanced
888 pages
16h 55m
English
A date and time can be formatted as a string in many different ways because of abbreviations, varying punctuation, different orderings, and so on. Because of the various ways of formatting, writing code to decipher such a character string can be daunting. Consider these examples:
s1 = "9/13/98 2:15am" s2 = "1961-05-31" s3 = "11 July 1924" s4 = "April 17, 1929" s5 = "20 July 1969 16:17 EDT" # That's one small step... s6 = "Mon Nov 13 2000" s7 = "August 24, 79" # Destruction of Pompeii s8 = "8/24/79"
Fortunately, much of the work has already been done for us. The ParseDate module has a single class of the same name, which has a single method called parsedate. This method returns an array of elements ...
Read now
Unlock full access