-
Notifications
You must be signed in to change notification settings - Fork 1.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
<chrono>
Formatting: C++20's Final Boss
#1870
<chrono>
Formatting: C++20's Final Boss
#1870
Commits on Apr 15, 2021
-
Co-authored-by: Elnar Dakeshov <55715127+eldakesh-ms@users.noreply.github.com> Co-authored-by: mnatsuhara <46756417+mnatsuhara@users.noreply.github.com>
Configuration menu - View commit details
-
Copy full SHA for 2118d1e - Browse repository at this point
Copy the full SHA 2118d1eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 33e3804 - Browse repository at this point
Copy the full SHA 33e3804View commit details -
Configuration menu - View commit details
-
Copy full SHA for cdfa88c - Browse repository at this point
Copy the full SHA cdfa88cView commit details -
chronat: Add year and year_month_day formatting (microsoft#1840)
* <chronat>: Add year and year_month_day formatting This one is a biggie. The main things changed are the way that specifiers are handled and delegated. The general idea behind formatting time is that you can take segments of a type and format them individually. For example, you can take the year out of year_month_day and do the exact same operations you can do with a normal year. The `_Is_type_valid` function recursively checks if a parent type can be formatted by its children. The other functions didn't really need much more finessing, the `tm` structure already has all the fields we need to hold all the time info (simultaniously) and the formatters work off that. The big change here is in moving some "basic" formatters into our own function and not relying on `get_time` to format them. The main reason is that `get_time` does not play with invalid ranges, at all. A day of `40` is always illegal, but we need to be able to format it, especially in the face of `operator <<`. We could have kept what we had before, but then it becomes a clear problem that we cannot use `%F` for a `year_month_day` that has an invalid day, so I am seperating all the integral formatters out into that function. Again, because of the nested nature of times, we recurse in this function. Note that function currently uses `format_to` in probably a very inneficient way. I am all ears on how to improve that. * Clang test * Finesse the tests * review * Comment update Co-authored-by: mnatsuhara <46756417+mnatsuhara@users.noreply.github.com> * PR fixes Co-authored-by: mnatsuhara <46756417+mnatsuhara@users.noreply.github.com>
Configuration menu - View commit details
-
Copy full SHA for 0aeb5ea - Browse repository at this point
Copy the full SHA 0aeb5eaView commit details -
Configuration menu - View commit details
-
Copy full SHA for 206727e - Browse repository at this point
Copy the full SHA 206727eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 1cb654b - Browse repository at this point
Copy the full SHA 1cb654bView commit details -
Configuration menu - View commit details
-
Copy full SHA for e7b705a - Browse repository at this point
Copy the full SHA e7b705aView commit details -
2
Configuration menu - View commit details
-
Copy full SHA for 5505ea3 - Browse repository at this point
Copy the full SHA 5505ea3View commit details
Commits on Apr 16, 2021
-
Configuration menu - View commit details
-
Copy full SHA for 4c236a3 - Browse repository at this point
Copy the full SHA 4c236a3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5bf0c50 - Browse repository at this point
Copy the full SHA 5bf0c50View commit details -
Update the modifier table, use uint8_t.
This follows N4885 [tab:time.format.spec]'s order, and adds {'z', _EO_mod} which was missing.
Configuration menu - View commit details
-
Copy full SHA for 1187292 - Browse repository at this point
Copy the full SHA 1187292View commit details -
Configuration menu - View commit details
-
Copy full SHA for 838cd1f - Browse repository at this point
Copy the full SHA 838cd1fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 3a19af7 - Browse repository at this point
Copy the full SHA 3a19af7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 889fe20 - Browse repository at this point
Copy the full SHA 889fe20View commit details -
Add/centralize formatters, replace operators.
* Mark _Fill_tm() as _NODISCARD. * Teach _Fill_tm() to handle year_month_day_MEOW by directly extracting components when possible, and constructing a year_month_day{} temporary only when necessary. * Replace all of the operator<<() implementations for calendrical types with their "Effects Equivalent To" implementations from the Standard (modified to follow our conventions and actually compile). This should handle the setw(8) case mentioned by P1361R2 section 6 item 5, whereas implementing operator<<() by calling other operator<<() is (apparently) doomed. * Note that each operator<<() won't compile until all of the formatters that it depends on have been implemented. * Teach _Is_valid_type() to accept year_month_day_MEOW. * Now that _Fill_tm() centralizes the "decompose a calendrical type into its components" logic, we can further centralize the formatter definitions with _Fill_tm_formatter. Unlike the operator<<() overloads (where I added all types), I'm not adding formatters for unimplemented types here. When they're implemented, they should also be able to use _Fill_tm_formatter, unless they need unusual processing beyond what _Fill_tm() provides. * In P0355R7_calendars_and_time_zones_formatting/test.cpp, add placeholder tests, and comment out test_hh_mm_ss_formatter()'s implementation for now.
Configuration menu - View commit details
-
Copy full SHA for 7ee91b1 - Browse repository at this point
Copy the full SHA 7ee91b1View commit details -
Configuration menu - View commit details
-
Copy full SHA for 48eb7f8 - Browse repository at this point
Copy the full SHA 48eb7f8View commit details -
Adds the formatter with special bounds check so that `put_time` doesn't assert. Small bugfix/simplification for when `ok()` needs to be checked. Before we call `put_time`, we should always bounds check. Custom %S writer added (and %T calls it too). This is necessary for proper fractional second printing.
Configuration menu - View commit details
-
Copy full SHA for 84760ea - Browse repository at this point
Copy the full SHA 84760eaView commit details -
Add month_day, month_day_last, and year_month formatting
Not too many tests but they reuse a lot of the same pathways. Wouldn't hurt to test more but the operator<< are fully passthrough to format so it's not too scary.
Configuration menu - View commit details
-
Copy full SHA for 29b7094 - Browse repository at this point
Copy the full SHA 29b7094View commit details -
Configuration menu - View commit details
-
Copy full SHA for f6ba00d - Browse repository at this point
Copy the full SHA f6ba00dView commit details -
chronat: Allow day from month_day_last conditionally (microsoft#1845)
Thanks to matt and stat on discord for mentioning these edge cases. I originally thought that you can't get a day from `month_day_last`, but it clearly makes sense, for most months. I changed some machinery around so that we can always intercept a specifier, which means that we need to do manual checking in the writer for localization. This PR is more to illustrate how a specifier may be intercepted, and that testing need only be done for specific types.
Configuration menu - View commit details
-
Copy full SHA for 0814ca2 - Browse repository at this point
Copy the full SHA 0814ca2View commit details -
chronat: Clock formatting (microsoft#1846)
* chronat: Clock formatting Adds formatting for clocks! Moved _Custom_write into the formatter so it can do special things (write timezones). _Write_seconds now writes leap seconds as 60 for utc clock time points. Taught _Fill_tm to work with time_points (in reality only system_clock and local_clock work). Add operator<< for all clocks except local-time-format-t (because I'm still not sure what that is). The base formatter stores a timezone abbreviation. This is only useful for the clocks, but it seemed like the simplest way to implement this feature. * Remove unnecessary _CharT param for _Custom_write. This is a member function of _Chrono_formatter which is already templated on _CharT. * typename _Ty::clock. Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
Configuration menu - View commit details
-
Copy full SHA for a0f6558 - Browse repository at this point
Copy the full SHA a0f6558View commit details
Commits on Apr 17, 2021
-
wd, wdi formatting (microsoft#1847)
* wd, wdi formatting * Update libcxx skips. * Arrange formatters in Standard order. Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
Configuration menu - View commit details
-
Copy full SHA for d418366 - Browse repository at this point
Copy the full SHA d418366View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8aeda0c - Browse repository at this point
Copy the full SHA 8aeda0cView commit details -
<chrono>
formatting: fix UB, various cleanups (microsoft#1848)* Fix UB, various cleanups. * Optimize with common_type_t<_Duration, days>. Co-authored-by: MattStephanson <68978048+MattStephanson@users.noreply.github.com>
Configuration menu - View commit details
-
Copy full SHA for 6c06f23 - Browse repository at this point
Copy the full SHA 6c06f23View commit details -
<chrono>
: Implement exception class constructors (microsoft#1849)* hh_mm_ss::hours() is already an absolute value. Co-authored-by: statementreply <statementreply@gmail.com> * Implement nonexistent_local_time/ambiguous_local_time. * Test nonexistent_local_time/ambiguous_local_time. * Fix P0355R7_calendars_and_time_zones_time_zones. We can't use floating-point durations because the exception constructors in [time.zone.exception] will stream local_time<Duration>, and [time.clock.local] implements that by streaming sys_time<Duration>, and that's constrained by [time.clock.system.nonmembers] to reject floating-point durations. Co-authored-by: statementreply <statementreply@gmail.com>
Configuration menu - View commit details
-
Copy full SHA for d718499 - Browse repository at this point
Copy the full SHA d718499View commit details
Commits on Apr 18, 2021
-
<chrono>
formatting:weekday_last
,month_weekday
, `month_weekda……y_last` (microsoft#1854) * Add/test weekday_last, month_weekday, month_weekday_last. * In _Fill_tm(): + weekday_indexed and weekday_last can share code. + month_weekday and month_weekday_last have different accessors. + Cleanup: Unify the code for year_month_weekday and year_month_weekday_last. * In _Is_valid_type(): + weekday, weekday_indexed, and weekday_last all support the "weekday types". + month_weekday and month_weekday_last support "month types" and "weekday types". (As mentioned above, their accessors are actually weekday_indexed() and weekday_last(), but it seemed pointless to have separate cases to "recurse" into the weekday_indexed and weekday_last types, when the answer is always the same.) + Remove TRANSITION and change the final static_assert to "should be unreachable", which is the pattern that we use elsewhere. * Add the new formatters, all powered by _Fill_tm_formatter. In P0355R7_calendars_and_time_zones_formatting/test.cpp: * Rename charT to CharT for consistency (this is needed by the STR macro, if it were ever used in these functions). * Add empty_braces_helper() to test both format("{}") and operator<<. This should supersede stream_helper() but I'm not making that change here. * Test the new types. * Implement tests for year_month_day_last, year_month_weekday, and year_month_weekday_last now that the necessary formatters are available. * Call the new test functions. * Update libcxx skips for C++20 features.
Configuration menu - View commit details
-
Copy full SHA for d705b61 - Browse repository at this point
Copy the full SHA d705b61View commit details -
<chrono>
formatting: More cleanups (microsoft#1857)* Rearrange tests to follow Standard order. No other changes. * Move _Chrono_formatter into namespace chrono. No changes other than (greatly reduced!) qualification and formatting. _Fill_tm_formatter is still directly within std, as it's the base class for std::formatter. * Rename _Chrono_specs to _Chrono_spec. Drop "with literal chars" from a comment; this reflected our earlier, incorrect understanding. This also renames _Custom_write()'s parameter from _Specs to _Spec, avoiding shadowing a data member.
Configuration menu - View commit details
-
Copy full SHA for 1f874eb - Browse repository at this point
Copy the full SHA 1f874ebView commit details
Commits on Apr 19, 2021
-
<chrono>
formatting: Simplify test (microsoft#1859)* Replace stream_helper with empty_braces_helper. * Replace assert(format(STR("{}"), A) == B) with empty_braces_helper(A, B). * Remove duplicate lines. * Simplify choose_literal, use STR consistently.
Configuration menu - View commit details
-
Copy full SHA for c06416c - Browse repository at this point
Copy the full SHA c06416cView commit details -
chronat: Add duration formatter (microsoft#1861)
* chronat: Add duration formatter Special specifiers for duration are `j q Q`. Otherwise duration is very similar to `hh_mm_ss` except that times are interpreted as time from midnight. I thought this would mean that negative times are yesterday, but we just append a `-` instead, which means we should round instead of flooring to a day when computing hh/mm/ss. Other behavior is pretty simple. * Add typename. * Comments Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
Configuration menu - View commit details
-
Copy full SHA for 229dfde - Browse repository at this point
Copy the full SHA 229dfdeView commit details
Commits on Apr 20, 2021
-
<chrono>
formatting:sys_info
,local_info
, feature-test macro (m……icrosoft#1860) * Define and test the feature-test macro. * Implement and test sys_info and local_info. * Update libcxx skips. * Additionally test zero and half-hour offsets. * Print `seconds offset` and `minutes save`. * Add TRANSITION comment.
Configuration menu - View commit details
-
Copy full SHA for 39c722f - Browse repository at this point
Copy the full SHA 39c722fView commit details -
Configuration menu - View commit details
-
Copy full SHA for d69d7ba - Browse repository at this point
Copy the full SHA d69d7baView commit details -
<chrono>: Add %j support and expand %aAuw (microsoft#1864)
* <chrono>: Add %j support and expand %aAuw Adds %j support to all the classes that can benefit from it. This means all year_month_day* but and month_last (but only for January). Changes %aAuw to throw on invalid weekdays, but still work if the weekday is explicitly ok (so a bad year_month_day will always throw but a bad year_month_weekday can still print the weekday if that portion is ok). * Add month_day support * Make put_time strings uniformly
Configuration menu - View commit details
-
Copy full SHA for 65ad8a7 - Browse repository at this point
Copy the full SHA 65ad8a7View commit details -
<chrono: Rewrite %r spec for C locale (microsoft#1865)
put_time(%r) does the wrong thing when we use the C locale, due to some internal machinery. It could get fixed further down level, but that change is a lot more impactful. Instead, we simply rewrite %r when the C locale is used in chrono. This basically has to do with the way that _Strftime, _Gettnames, and expand_time work together. _Gettnames returns a copy of its data and expand_time figures out the locale based on pointer comparison.
Configuration menu - View commit details
-
Copy full SHA for d488200 - Browse repository at this point
Copy the full SHA d488200View commit details -
<chrono>: Fix hh_mm_ss subsecond formatting for floats (microsoft#1866)
* <chrono>: Fix hh_mm_ss subsecond formatting for floats Before, the same formatting string was used for floats and integrals. This meant that large floats were formatted using exponent notaion and small floats were not, and it also meant there was an extra period in a time, as the subseconds could be fractions of a subsecond (say .4 nanoseconds). Now if the subseconds are floats, we force fixed formatting to get the right number of leading zeroes and a precision of 0 to round off fractions of subseconds. * Floor subseconds
Configuration menu - View commit details
-
Copy full SHA for cc2651d - Browse repository at this point
Copy the full SHA cc2651dView commit details
Commits on Apr 21, 2021
-
<chrono>: Fix utc_clock seconds formatting (microsoft#1868)
Co-authored-by: MattStephanson <68978048+MattStephanson@users.noreply.github.com> Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
Configuration menu - View commit details
-
Copy full SHA for cec735c - Browse repository at this point
Copy the full SHA cec735cView commit details -
<chrono>
formatting: extend%r
, add%g %G %U %V %W
(microsoft#1869Configuration menu - View commit details
-
Copy full SHA for e015c35 - Browse repository at this point
Copy the full SHA e015c35View commit details -
<chrono>: Fine grained bounds checking (microsoft#1871)
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net> Co-authored-by: mnatsuhara <46756417+mnatsuhara@users.noreply.github.com>
Configuration menu - View commit details
-
Copy full SHA for d652eab - Browse repository at this point
Copy the full SHA d652eabView commit details -
Configuration menu - View commit details
-
Copy full SHA for 360e631 - Browse repository at this point
Copy the full SHA 360e631View commit details -
Configuration menu - View commit details
-
Copy full SHA for bd5b397 - Browse repository at this point
Copy the full SHA bd5b397View commit details
Commits on Apr 22, 2021
-
Configuration menu - View commit details
-
Copy full SHA for 7c177d0 - Browse repository at this point
Copy the full SHA 7c177d0View commit details -
Configuration menu - View commit details
-
Copy full SHA for ab1001c - Browse repository at this point
Copy the full SHA ab1001cView commit details