-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Replacing strftime with std::time_put #2550
Conversation
f8410da
to
330f39d
Compare
We should definitely use built-in names in this case. |
1d04758
to
623cc58
Compare
Done, with workaround to strange C-locale |
6a89657
to
5cae10b
Compare
@vitaut I think the PR is ready for a review. |
There was a problem hiding this 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.
include/fmt/chrono.h
Outdated
char modifier) -> std::string { | ||
auto&& os = std::ostringstream(); | ||
char modifier) | ||
-> decltype(std::basic_ostringstream<Char>().str()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
decltype(std::basic_ostringstream<Char>().str())
-> std::basic_string<Char>
Also please move the overflow fix to a separate PR. |
Now that the overflow fix is merged (thanks for moving into a separate PR), please rebase this one. |
5cae10b
to
6e4b06d
Compare
@vitaut PR is updated. Please review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, just minor comments left.
include/fmt/chrono.h
Outdated
#ifdef _WIN32 | ||
on_us_date(); | ||
*out_++ = ' '; | ||
on_iso_time(); | ||
#else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The locale-independent and C locale format should be consistent among platforms so let's remove this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Corresponding tests for Windows are disabled (https://github.com/fmtlib/fmt/runs/4055476293?check_suite_focus=true)
include/fmt/chrono.h
Outdated
#ifdef _WIN32 | ||
on_iso_time(); | ||
#else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove this as well.
ea7af83
to
cc20c47
Compare
test/chrono-test.cc
Outdated
spec_list.push_back("%Y-%m-%d %H:%M:%S"); | ||
#ifndef _WIN32 | ||
// Disabled on Windows, because this formats is not consistent among platforms |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this -> these and please add punctuation (.) at the end of the sentence.
cc20c47
to
a9df99f
Compare
Thank you! |
* Fix unicode test * Add xchar support to chrono formatter * Replace strftime with std::time_put * Add std::locale support to std::tm formatter * Use predefined names and formats for C-locale * Performance improvement * Make locale-independent and C locale formats consistent among platforms
Continuation of PR #2544.
Draft, because I haven't yet tested the PR in all my environments.@vitaut, what do you think about using the built-in month and weekday names in the case of the
std::locale::classic()
locale (withoutstd::time_put
calls)?