Tuesday, 13 August 2013

Datetime anomaly with abreviated months

Datetime anomaly with abreviated months

I cannot fathom what is going in the following example
>>> datetime.datetime.strptime("Aug 10", "%b %y")
datetime.datetime(2010, 8, 1, 0, 0)
Makes sense %b is abreviated month name and %y is year so August 2010
corresponds to datetime(2010, 8, 1, 0, 0)
However if i change %y to %m, where %m is day of the month it gets weird
>>> datetime.datetime.strptime("Aug 10", "%b %m")
datetime.datetime(1900, 10, 1, 0, 0)
All of a sudden it refuses to recognize "Aug"

No comments:

Post a Comment