I am working on old text files with 2-digit years where the default century logic in dateutil.parser
doesn't seem to work well. For example, the attack on Pearl Harbor was not on dparser.parse("12/7/41")
(which returns 2041-12-7).
The buit-in century "threshold" to roll back into the 1900's seems to happen at 66:
import dateutil.parser as dparser
print(dparser.parse("12/31/65")) # goes forward to 2065-12-31 00:00:00
print(dparser.parse("1/1/66")) # goes back to 1966-01-01 00:00:00
For my purposes I would like to set this "threshold" at 17, so that:
"12/31/16"
parses to 2016-12-31 (yyyy-mm-dd
)"1/1/17"
parses to 1917-01-01
But I would like to continue to use this module as its fuzzy match seems to be working well.
The documentation doesn't identify a parameter for doing this... is there an argument I'm overlooking?
convertyear
. – Blackshear