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

Improve the parsing of time spans #3130

Merged
merged 3 commits into from
Oct 1, 2021
Merged

Conversation

pleroy
Copy link
Member

@pleroy pleroy commented Sep 30, 2021

We now accept formats like:

7d
7d 6h
7d 6h 5min
7d 6h 5min 4s

With d replaced by d6 as appropriate.

Example here.

Fix #2984.

}
@"\s*" +
@"(?:(?<hours>\d+)\s*h\s*" +
@"(?:(?<minutes>\d+)\s*min\s*"+
Copy link
Member

Choose a reason for hiding this comment

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

missing space before +.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Sorry, something went wrong.

seconds = match.Groups[4].Value;
}

string days = match.Groups["days"].Value;
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn’t the days be optional as well ? Having to write "5 h" as "0 d6 5 h" seems annoying.

Sorry, something went wrong.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated the regexp so that all components are optional, example here. Also fix a glitch where the data was not reformatted if it was numerically identical.

@eggrobin eggrobin added the LGTM label Oct 1, 2021
@pleroy pleroy merged commit ace078d into mockingbirdnest:master Oct 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The duration parsers should allow for missing units
2 participants