-
-
Notifications
You must be signed in to change notification settings - Fork 694
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
Validater for if arrow.get() properly parsed the date. #399
Comments
The issue causing this is that the parser is only parsing the year correctly.
This mainly due to the way the formats are generated. Adding some common formats into the mix might alleviate some the issues, but best practice seems to always use tokens to explicitly tell the parser how to read the date.
|
I do not want to have to specify formats. The reason for using arrow over datetime is purely because .get() in theory is supposed to be able to normalize inputs. Other time libraries like moment.js have no problem figuring out what '10-10-2016' means. Or at the very least arrow should not be returning an object with the wrong date and month because that will just mean silent errors.
|
While current Moment will parse that string, it is deprecated and being removed in a future release. We don't plan to support it either as it is an non-standard iso format.
Fiddle to show example: https://jsfiddle.net/f4vxajpj/ |
Is there a way at least to see if the format has been properly parsed by arrow? In a generic sense where I don't need to specify a list of formats. |
That's tricky because it goes through a bunch of formats to try and match anything in the string. In this case it's able to match on the year, so it is returning that. Not ideal for your use case, I'm aware. Perhaps something can be done in https://github.com/crsmithdev/arrow/blob/master/arrow/parser.py#L271 |
Thanks that looks promising! |
Not quite sure how to handle this currently. Reopening for a future look. |
We (or rather I) will probably look at this sometime at work so if I do get a small solution specifically for my use case I'll let you know. My current initial impression (no IDE atm to step through) based on the code is something in .parse() would need to be modified when the formats are being generated. Either that or maybe in builddatetime where a kwarg is passed like 'enforce complete date' or 'validator' (lambda/func) that checks to make sure year/month/date has been parsed (for my use case anyway, for others they may want more accuracy). Thanks for reopening. |
@rhan-mentad If you have the time to step through and at minimum get a rough PR together that would be appreciated. I'd like to handle two situations which might be fixed with the same code:
|
It'd be simple, just have it have a callback keyword that it calls to report the tokens it matched. Users can then write a function to check the appropriateness of the parsing or just use the print function to display ut |
Will be handled by #91 . Let me know if you make any progress on the PR. I would love to take a look. |
Using latest version of arrow
The text was updated successfully, but these errors were encountered: