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

Implement 'chrono' formatting specifiers '%Q' and '%q' (#1004) #1019

Merged
merged 1 commit into from
Jan 27, 2019

Conversation

DanielaE
Copy link
Contributor

Howard Hinnant's 'date' library recently gained these two new formatting specifiers. This implementation in {fmt} includes support for 'std::chrono::duration' specializations with floating-point representation types and user-definable precision.

Signed-off-by: Daniela Engert dani@ngrt.de

Copy link
Contributor

@vitaut vitaut left a comment

Choose a reason for hiding this comment

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

LGTM, just minor comments inline. Thanks for the PR.

@@ -18,6 +18,33 @@

FMT_BEGIN_NAMESPACE

template <typename Period> FMT_CONSTEXPR const char* get_units() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This and specializations should probably be internal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, done

@@ -118,6 +145,12 @@ FMT_CONSTEXPR const Char* parse_chrono_format(const Char* begin,
case 'p':
handler.on_am_pm();
break;
case 'Q':
handler.on_value();
Copy link
Contributor

Choose a reason for hiding this comment

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

on_value is a bit too generic. What kind of value is allowed here, time?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to clarify the intent.

Howard Hinnant's 'date' library recently gained these two new formatting specifiers. This implementation in {fmt} includes support for 'std::chrono::duration' specializations with floating-point representation types and user-definable precision.

Signed-off-by: Daniela Engert <dani@ngrt.de>
@vitaut vitaut merged commit 0700612 into fmtlib:master Jan 27, 2019
@DanielaE DanielaE deleted the feature/chrono-specs-%Q+%q branch January 28, 2019 06: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.

2 participants