Skip to content

Support various number of digits after the comma in the timestamp %f …#178

Merged
wimglenn merged 1 commit intor1chardj0n3s:masterfrom
bbertincourt:support-for-milliseconds-in-datetime-format
Jan 28, 2024
Merged

Support various number of digits after the comma in the timestamp %f …#178
wimglenn merged 1 commit intor1chardj0n3s:masterfrom
bbertincourt:support-for-milliseconds-in-datetime-format

Conversation

@bbertincourt
Copy link
Copy Markdown
Contributor

…format

This PR adds a small modification to support various number of digits (1 to 6) after the comma to be picked up and recognized by the "%f" directive as it does with datetime.strptime.

I believe this also answers #127

Current State

from parse import parse

ok_result = parse("{:%H:%M:%S.%f}", "12:34:56.789000")
print(ok_result)

fail_result = parse("{:%H:%M:%S.%f}", "12:34:56.789")
print(fail_result)  # is None

Output[]

<Result (datetime.time(12, 34, 56, 789000),) {}>
None

Desired State

Output[]

<Result (datetime.time(12, 34, 56, 789000),) {}>
<Result (datetime.time(12, 34, 56, 789000),) {}>

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jan 28, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.65%. Comparing base (8ae5d30) to head (b1d2121).
Report is 8 commits behind head on master.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #178   +/-   ##
=======================================
  Coverage   94.65%   94.65%           
=======================================
  Files           1        1           
  Lines         543      543           
  Branches      132      132           
=======================================
  Hits          514      514           
  Misses         18       18           
  Partials       11       11           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@wimglenn wimglenn merged commit 79f516d into r1chardj0n3s:master Jan 28, 2024
@wimglenn
Copy link
Copy Markdown
Collaborator

This seems reasonable. Thanks for the contribution!

@bbertincourt
Copy link
Copy Markdown
Contributor Author

@wimglenn I have these weirdly formatted log exports that parse does a really good job on. Helps me really, thanks for maintaining parse.

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.

3 participants