-
-
Notifications
You must be signed in to change notification settings - Fork 678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improving get method #538
Comments
How does this lib handle dates like |
You can specify what you are parsing with ".format("DD/MM/YYYY)" The default should be this MM/DD/YYYY Btw is this related to the issue? |
@aster94 If anything the default should probably be DMY as its used in more countries than MDY. |
Hi, |
The current situation. Python 3.6.7 (default, Oct 25 2018, 09:16:13)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import arrow
>>> d = ["01/01/2001", "2/2/2002", "03/03/03", "04-04-2004"]
>>> for ts in d:
... arrow.get(ts)
...
<Arrow [2001-01-01T00:00:00+00:00]>
<Arrow [2002-01-01T00:00:00+00:00]>
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "/home/chris/arrow/arrow/api.py", line 22, in get
return _factory.get(*args, **kwargs)
File "/home/chris/arrow/arrow/factory.py", line 174, in get
dt = parser.DateTimeParser(locale).parse_iso(arg)
File "/home/chris/arrow/arrow/parser.py", line 119, in parse_iso
return self._parse_multiformat(string, formats)
File "/home/chris/arrow/arrow/parser.py", line 286, in _parse_multiformat
raise ParserError('Could not match input to any of {} on \'{}\''.format(formats, string))
arrow.parser.ParserError: Could not match input to any of ['YYYY-MM-DD', 'YYYY/MM/DD', 'YYYY.MM.DD', 'YYYY-MM', 'YYYY/MM', 'YYYY.MM', 'YYYY', 'YYYY', 'YYYY'] on '03/03/03'
<Arrow [2004-01-01T00:00:00+00:00]> 2nd and 4th results are examples of .get() returning very hard to detect errors rather than simply failing. This is already reported and needs to be fixed, I also suspect 1st result is lucky rather than reliable. 3rd result is kind of whatever tbh. Until the .get() problem is fixed I strongly advise you to always pass formats if possible. |
hello,
i would like to ask for a new feature which is present in other library which manages times, for example in moment
in that module i can do something like
moment.date(d)
where d is 01/01/2001 or 1/1/2001 or 01/01/01 or 01-01-2001
i am trying to say that it accept quite everything, it would be nice if get() was able to be feed with everything too
here there is a code snippet if you want to try
The text was updated successfully, but these errors were encountered: