Skip to content

Adopt prefixdate library for parsing dates#441

Merged
pudo merged 3 commits into
masterfrom
pudo/adopt-prefixdate
Jul 20, 2021
Merged

Adopt prefixdate library for parsing dates#441
pudo merged 3 commits into
masterfrom
pudo/adopt-prefixdate

Conversation

@pudo

@pudo pudo commented Jul 6, 2021

Copy link
Copy Markdown
Contributor

This would adopt the prefixdate library, which makes some of the logic of the existing date parsing more explicit. When applied, this should:

a) Speed up date processing, both for format-string based parsing and for normal validation.
b) Truncate prefixes for minutes and seconds from times when they are 00.
c) Fix an apparent issue with time zone conversion in to_datetime.

@Rosencrantz Rosencrantz self-requested a review July 8, 2021 06:18

@Rosencrantz Rosencrantz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, just so I understand what you're proposing here. You're looking to remove the big, ugly Regex with a library that does the same thing, and this is why most of this PR is removing code?

@pudo

pudo commented Jul 8, 2021

Copy link
Copy Markdown
Contributor Author

Haha, I guess the point is that the library uses one fat regex to do a lot of the stuff that's happening in individual steps here (like that weird CUT_ZEROES thing)...

One thing that's a bit "complicated" is that prefixdate disregards unknown suffixes on dates that it does not understand. That means 2001BANANA is a valid date, and will normalise to 2001. That's needed to pass the existing ftm tests, which contain some weird examples. Maybe we could at some point adapt and get more strict.

@pudo

pudo commented Jul 16, 2021

Copy link
Copy Markdown
Contributor Author

OK, the time issue is fixed.

@pudo pudo requested a review from Rosencrantz July 16, 2021 10:45
Comment thread tests/types/test_dates.py Outdated
@pudo pudo merged commit a1f26be into master Jul 20, 2021
@pudo pudo deleted the pudo/adopt-prefixdate branch July 20, 2021 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants