Reference no: EM132184077
Define a function dateToNum(..) which receives as parameter a string representing a date in the format:
"d-mmm-yy", "d-mmm-y", "dd-mmm-yy" or "dd-mmm-y" (for example "2-Jan-18", "5-Jan-8", "25-Dec-17", "21-Apr-1")
(that is, the days and the years may be represented with one or two digits, the month with the first three letters of the month name (starting with uppercase and rest lowercase).
The function should return a list with three numbers: [y,m,d].
Considering the examples, respectively the list returned would be [2018,1,2] , [2008,1,5], [2017,12,25], [2001,4,21]
(that is, the year is assumed 2001 or later)
As an example, the following code fragment:
st = "2-Jan-18"
print(dateToNum(st))
should produce the output:
[2018, 1, 2]
Program language: python