Skip to content
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

move comma-microsecond logic from timelex to parser #738

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jbrockmendel
Copy link
Contributor

This looks small, but is somewhat far-reaching.

  • Treat commas as a decimal exclusively in seconds. ATM if parse '2003 May 4, 14:10,7' the 10,7 gets treated as "10.7 minutes", which I do not think is intended.

  • By getting rid of the comma in _split_decimal, we can further simplify simplify+optimize timelex #732 to get rid of the second-pass which is the main point of ugliness there.

  • If there is no decimal separator in a seconds token, return None as the microseconds instead of 0. Down the road this will be useful for keeping track of resolution information.

@jbrockmendel
Copy link
Contributor Author

This will need tests before being mergeable. Before that we need to make a decision about the behaviors that this changes, in particular, do we allow commas as a decimal separator for minutes, or only for seconds? If we allow them for minutes, I'll need to patch this.

@@ -57,7 +57,7 @@
# take off their plate.
class _timelex(object):
# Fractional seconds are sometimes split by a comma
_split_decimal = re.compile("([.,])")
_split_decimal = re.compile("([.])")
Copy link
Member

Choose a reason for hiding this comment

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

If we're moving the logic into the parser, we don't have to use a compiled regular expression, since I believe token.split('.') will work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea.

IIRC the status of this is that it needs to entail zero behavioral changes. That is not yet the case with this PR; I'll move this up the priority list.

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