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

Advance POT-Creation-Date by 1 minute on normalization #212

Merged
merged 3 commits into from
Jul 19, 2024

Conversation

carreter
Copy link
Contributor

@carreter carreter commented Jul 9, 2024

Fixes #117.

Advances POT-Creation-Date by 1 minute rather than 1 second as @mgeisler suggested as it seems like the date format does not include seconds for some reason: https://www.gnu.org/software/trans-coord/manual/gnun/html_node/PO-Header.html

"POT-Creation-Date: 2008-02-06 16:25-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"

Copy link
Collaborator

@mgeisler mgeisler left a comment

Choose a reason for hiding this comment

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

Thanks a lot, this looks great! I just think we should avoid erroring out in case the date cannot be parsed for some unknown reason.

if let Ok(pot_creation_date) = dateparser::parse(&new_catalog.metadata.pot_creation_date) {
new_catalog.metadata.pot_creation_date = pot_creation_date
.checked_add_signed(Duration::minutes(1))
.ok_or(anyhow::Error::msg("could not advance POT-Creation-Date"))?
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you instead leave the date unchanged if it cannot be parsed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@@ -566,4 +576,12 @@ mod tests {
],
);
}

#[test]
fn test_normalize_pot_creation_date() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please also add a test for the case where the date cannot be parsed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@mgeisler
Copy link
Collaborator

Advances POT-Creation-Date by 1 minute rather than 1 second as @mgeisler suggested as it seems like the date format does not include seconds for some reason: https://www.gnu.org/software/trans-coord/manual/gnun/html_node/PO-Header.html

Nice, I had not noticed that 😄

@codecov-commenter
Copy link

codecov-commenter commented Jul 10, 2024

Codecov Report

Attention: Patch coverage is 96.15385% with 1 line in your changes missing coverage. Please review.

Project coverage is 84.82%. Comparing base (68d2e29) to head (04d6b15).
Report is 5 commits behind head on main.

Files Patch % Lines
i18n-helpers/src/normalize.rs 96.15% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #212      +/-   ##
==========================================
- Coverage   86.99%   84.82%   -2.17%     
==========================================
  Files          15       15              
  Lines        3229     3341     +112     
  Branches     3229     3341     +112     
==========================================
+ Hits         2809     2834      +25     
- Misses        327      413      +86     
- Partials       93       94       +1     

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

@carreter carreter requested a review from mgeisler July 11, 2024 18:35
Copy link
Collaborator

@mgeisler mgeisler left a comment

Choose a reason for hiding this comment

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

Thanks, looks great!

@carreter
Copy link
Contributor Author

@mgeisler Fixed the linting issues, mind giving approval for the workflow?

@kdarkhan kdarkhan merged commit aa3c0bc into google:main Jul 19, 2024
7 checks passed
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.

Advance POT-Creation-Date by 1 second in mdbook-i18n-normalize
4 participants