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 glibc ext for sec, min, and hour #3271

Merged
merged 6 commits into from
Feb 8, 2023

Conversation

ShawnZhong
Copy link
Contributor

@ShawnZhong ShawnZhong commented Jan 13, 2023

Fix #2959

@ShawnZhong ShawnZhong force-pushed the glibc_ext branch 3 times, most recently from b9f8bf1 to 0f10801 Compare January 13, 2023 10:58
include/fmt/chrono.h Outdated Show resolved Hide resolved
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.

Thanks for the PR. Overall looks good, just minor comments/questions inline.

@@ -664,6 +664,30 @@ enum class numeric_system {
alternative
};

// Glibc extensions for formatting numeric values.
enum class pad_type {
unspecified,
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need unspecified? It looks like it's always handled as zero and can be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Based on the current codebase, yes.

Comment on lines +672 to +673
// Pad a numeric result string with zeros even if the conversion specifier
// character uses space-padding by default.
Copy link
Contributor

Choose a reason for hiding this comment

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

Which conversion specifiers use space padding by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For example, the command date "+%10a" prints Tue on Ubuntu 22.04.1.
If we were to implement the glibc extension for the optional width, we might need to consider this padding. Otherwise, we don't have space padding in the current codebase.

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.

@ShawnZhong, thanks for the PR. It looks good overall but I have some minor questions (inline).

@chris-morgan
Copy link

This missed some things:

  • Documentation in doc/syntax.rst
  • Support for applying these padding flags to all numeric types, not just HIMS (all timey): those missing are CdegGjmUVWyY (all calendrical). Or, at the very least, explicit documentation of the incompleteness of flag support relative to glibc.

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.

Support strftime - extension
4 participants