Reputation: 170
May someone explain me why I have this behaviour with the 't' parameter
from dateutil.parser import parse
parse('t')
Out[4]: datetime.datetime(2016, 4, 28, 0, 0)
When I except :
parse('z')
Traceback (most recent call last):
[...]
ValueError: Unknown string format
Upvotes: 2
Views: 127
Reputation: 473873
t
is a special case since it is one of the "jump" values (it's usage while parsing is here):
JUMP = [" ", ".", ",", ";", "-", "/", "'",
"at", "on", "and", "ad", "m", "t", "of",
"st", "nd", "rd", "th"]
In other words, parsing t
, m
would not result into an "Unknown string format" error.
The z
is a special case too since it can have a special meaning - "zulu"/"zero offset" (which is part of the ISO 8601 standard), but that does not affect the results much, parse("q")
or parse("u")
would also produce an "Unknown string format" error.
Both parse("t")
and parse("z")
would result into a default/current date in "fuzzy" mode:
>>> parse('t', fuzzy=True)
datetime.datetime(2016, 4, 28, 0, 0)
>>> parse('z', fuzzy=True)
datetime.datetime(2016, 4, 28, 0, 0)
Upvotes: 1