-
Notifications
You must be signed in to change notification settings - Fork 18
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
add datetime parser #12
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add a relaxed datetime parser. This datetime parser functions by using `chrono`s own parsing utilities and a try/succeed approach to parsing. This implementation of the datetime parser has some drawbacks and some positives. On the positive side: - it was easy to implement - it is easy to add more datetime formats to In order to add additionally supported formats, a developer can add the required format string to the `format` mod in `parse_datetime.rs`, and then add it as a potential format to the relevant `fmts` vec. On the negative: - It is not easily customiseable beyond the supported `chrono` parsing formats. E.g., `chrono` does not currently support parsing offsets without trailing zeros. `from_str("UTC+1")` should return a valid response but `chrono` fails to parse this. - Because it is an attempt driven parser, it is likely not that performant. I have not done any performance testing as part of this change, but I would expect a custom parser to perform much better.
sylvestre
reviewed
Jun 5, 2023
sylvestre
reviewed
Jun 5, 2023
sylvestre
reviewed
Jun 5, 2023
sylvestre
reviewed
Jun 5, 2023
Co-authored-by: Sylvestre Ledru <sledru@mozilla.com>
Codecov Report
@@ Coverage Diff @@
## main #12 +/- ##
===========================================
+ Coverage 41.87% 64.97% +23.09%
===========================================
Files 2 3 +1
Lines 511 454 -57
Branches 100 93 -7
===========================================
+ Hits 214 295 +81
+ Misses 259 111 -148
- Partials 38 48 +10
Flags with carried forward coverage won't be shown. Click here to find out more.
|
looks good. could you please update the readme too ? |
Update the README and add a test module to parse_datetime for any examples presented in the README.
Just updated! |
mvo5
added a commit
to mvo5/coreutils
that referenced
this pull request
Mar 30, 2024
This commit is a trivial followup for: uutils#4917 and uutils/parse_datetime#12 The functionality to parse the datetime was moved into the parse_datetime crate and the only (tiny) piece left is to call it from `date`. It also adds the two tests from the original PR#4917. Closes: uutils#4657 Thanks to Ben Schofield
mvo5
added a commit
to mvo5/coreutils
that referenced
this pull request
Mar 30, 2024
This commit is a trivial followup for: uutils#4917 and uutils/parse_datetime#12 The functionality to parse the datetime was moved into the parse_datetime crate and the only (tiny) piece left is to call it from `date`. It also adds the test-case from the original issue. I did not include the two tests from PR#4917 because they appear to work even without this change. I am happy to include them of course if prefered. Closes: uutils#4657 Thanks to Ben Schofield
cakebaker
pushed a commit
to uutils/coreutils
that referenced
this pull request
Mar 30, 2024
* date: fix `date -f dates.txt is failing` This commit is a trivial followup for: #4917 and uutils/parse_datetime#12 The functionality to parse the datetime was moved into the parse_datetime crate and the only (tiny) piece left is to call it from `date`. It also adds the test-case from the original issue. I did not include the two tests from PR#4917 because they appear to work even without this change. I am happy to include them of course if prefered. Closes: #4657 Thanks to Ben Schofield * tests: tweak changes to test_date.rs to be more idiomatic Co-authored-by: Sylvestre Ledru <sylvestre@debian.org> --------- Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Moving PR from main coreutils to this crate, after discussion here: uutils/coreutils#4917
Add a relaxed datetime parser. This datetime parser functions by using
chrono
s own parsing utilities and a try/succeed approach to parsing.This implementation of the datetime parser has some drawbacks and some positives. On the positive side:
In order to add additionally supported formats, a developer can add the required format string to the
format
mod inparse_datetime.rs
, and then add it as a potential format to the relevantfmts
vec.On the negative:
chrono
parsing formats. E.g.,chrono
does not currently support parsing offsets without trailing zeros.from_str("UTC+1")
should return a valid response butchrono
fails to parse this.Remaining todo: