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

Support strftime and strptime equivalent for formatting and parsing #190

Merged

Conversation

ChristopherRabotin
Copy link
Member

@ChristopherRabotin ChristopherRabotin commented Dec 8, 2022

For #182, this adds support for the computation of Day of Year (e.g. 059 for the 29th of February 2000). This also supports initialization of an Epoch provided the year, the Day of Year, and the time scale.

For #181, this adds support for custom formatting rules, as well as providing a number of standard formats like RFC2820. This also introduced the month name structure. This structure is used strictly for formatting and has no other use. It is therefore extremely limited in scope.

Notes on the implementation of the parsing: if the week day is provided in the format and the string to parse leads to an Epoch whose week day is different from the one provided, the parsing will return an error.

@gwbres I've added you as a reviewer since you've contributed a lot recently. I'll be self-reviewing the changes proposed here anyway, but a second pair of eyes is always useful.

Remaining TODOs:

  • Parsing provided an EpochFormat and a string
  • Convert the current from_str to the parsing method above (I'm unsure about this because the current from_str is quite well optimized so there may be some performance degradation if the switch is made).

…tialization

Signed-off-by: Christopher Rabotin <christopher.rabotin@gmail.com>
Signed-off-by: Christopher Rabotin <christopher.rabotin@gmail.com>
This basically adds strftime to hifitime.

Will now work on the parser of the same kind. This may be a notch more challenging.

Signed-off-by: Christopher Rabotin <christopher.rabotin@gmail.com>
@codecov-commenter
Copy link

codecov-commenter commented Dec 8, 2022

Codecov Report

Base: 79.83% // Head: 77.67% // Decreases project coverage by -2.15% ⚠️

Coverage data is based on head (b1071b9) compared to base (09bfcf3).
Patch coverage: 69.43% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #190      +/-   ##
==========================================
- Coverage   79.83%   77.67%   -2.16%     
==========================================
  Files          10       14       +4     
  Lines        2886     3602     +716     
==========================================
+ Hits         2304     2798     +494     
- Misses        582      804     +222     
Impacted Files Coverage Δ
src/deprecated.rs 0.00% <0.00%> (ø)
src/lib.rs 100.00% <ø> (+42.85%) ⬆️
src/month.rs 30.90% <30.90%> (ø)
src/errors.rs 37.50% <37.50%> (ø)
src/efmt/formatter.rs 50.00% <50.00%> (ø)
src/duration.rs 82.18% <63.38%> (-1.83%) ⬇️
src/parser.rs 77.22% <69.23%> (-2.55%) ⬇️
src/efmt/format.rs 79.55% <79.55%> (ø)
src/epoch.rs 87.67% <96.59%> (+0.15%) ⬆️
src/timescale.rs 94.49% <100.00%> (+1.56%) ⬆️
... and 4 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Signed-off-by: Christopher Rabotin <christopher.rabotin@gmail.com>
Signed-off-by: Christopher Rabotin <christopher.rabotin@gmail.com>
@gwbres
Copy link
Collaborator

gwbres commented Dec 8, 2022

Hello Chris,

@gwbres I've added you as a reviewer since you've contributed a lot recently. I'll be self-reviewing the changes proposed here anyway, but a second pair of eyes is always useful.

thanks! I'll test this new content when I have a little time.

Wow this is very good Chris. This will probably help simplify operations like here where I need to parse an Epoch from a custom format, and generate it a few lines above

This should make for cleaner imports
Also refactored the formatting structures to be shorter
…year-initialization-and-formatting' into 182-support-day-of-year-initialization-and-formatting
Signed-off-by: Christopher Rabotin <christopher.rabotin@gmail.com>
…-formatting

Signed-off-by: Christopher Rabotin <christopher.rabotin@gmail.com>
+ Removed the `efmt` feature since the library size barely changes with
it.
+ Add IAI / Cachegrind based benchmarks.
@ChristopherRabotin ChristopherRabotin merged commit 2b3f6bc into master Dec 30, 2022
@ChristopherRabotin ChristopherRabotin deleted the 182-support-day-of-year-initialization-and-formatting branch December 30, 2022 05:30
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.

None yet

3 participants