I'm working on parsing log files, which have variable datetime formats in their timestamps. I am passing this string: Feb 22 08:58:24 router1 to dateutil.parser.parse() to try and extract the timestamp, like so:
>>> dateutil.parser.parse('Feb 22 08:58:24 router1', fuzzy=True) datetime.datetime(2001, 2, 22, 8, 58, 24) Which results in the date: February 22nd, 2001
Why is the year parsed as 2001 rather than the current year, 2019?
router1is being interpreted somehow as1and is mapping to 2001. Do you get the same result with the1orrouter1removedrouter 2prints2002, same for just2.routerbecausefuzzy=True, that's a little frustratingrouterbut not the1next to it. You can check this by passing thefuzzy_with_tokens=Truearg instead offuzzy=True