Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions stl/inc/chrono
Original file line number Diff line number Diff line change
Expand Up @@ -5464,6 +5464,10 @@ namespace chrono {
_Month = static_cast<unsigned int>(_Val);
} else if constexpr (is_same_v<_Ty, year>) {
_Year = static_cast<int>(_Val);
} else if constexpr (is_same_v<_Ty, weekday>) {
_Weekday = static_cast<int>(_Val.c_encoding());
} else if constexpr (is_same_v<_Ty, weekday_indexed>) {
_Weekday = static_cast<int>(_Val.weekday().c_encoding());
} else if constexpr (is_same_v<_Ty, month_day>) {
_Day = static_cast<unsigned int>(_Val.day());
_Month = static_cast<unsigned int>(_Val.month());
Expand Down Expand Up @@ -5744,7 +5748,7 @@ struct _Chrono_formatter {
return _Type == 'b' || _Type == 'B' || _Type == 'h' || _Type == 'm';
} else if constexpr (is_same_v<_Ty, _CHRONO year>) {
return _Type == 'Y' || _Type == 'y' || _Type == 'C';
} else if constexpr (is_same_v<_Ty, _CHRONO weekday>) {
} else if constexpr (_Is_any_of_v<_Ty, _CHRONO weekday, _CHRONO weekday_indexed>) {
return _Type == 'a' || _Type == 'A' || _Type == 'u' || _Type == 'w';
} else if constexpr (_Is_any_of_v<_Ty, _CHRONO month_day, _CHRONO month_day_last>) {
return _Is_valid_type<_CHRONO month>(_Type) || _Is_valid_type<_CHRONO day>(_Type);
Expand Down Expand Up @@ -5952,6 +5956,14 @@ template <class _CharT>
struct formatter<_CHRONO year, _CharT> //
: _Fill_tm_formatter<_CHRONO year, _CharT> {};

template <class _CharT>
struct formatter<_CHRONO weekday, _CharT> //
: _Fill_tm_formatter<_CHRONO weekday, _CharT> {};

template <class _CharT>
struct formatter<_CHRONO weekday_indexed, _CharT> //
: _Fill_tm_formatter<_CHRONO weekday_indexed, _CharT> {};

template <class _CharT>
struct formatter<_CHRONO month_day, _CharT> //
: _Fill_tm_formatter<_CHRONO month_day, _CharT> {};
Expand Down Expand Up @@ -6106,7 +6118,6 @@ template <class _Duration, class _CharT>
struct formatter<_CHRONO local_time<_Duration>, _CharT> //
: _Fill_tm_formatter<_CHRONO local_time<_Duration>, _CharT> {};


#endif // __cpp_lib_concepts
#endif // _HAS_CXX20

Expand Down
6 changes: 3 additions & 3 deletions tests/libcxx/expected_results.txt
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,8 @@ std/utilities/memory/default.allocator/allocator.members/allocate.verify.cpp SKI

# *** MISSING STL FEATURES ***
# C++20 P0355R7 "<chrono> Calendars And Time Zones"
std/utilities/time/time.cal/time.cal.mwd/time.cal.mwd.nonmembers/streaming.pass.cpp FAIL
std/utilities/time/time.cal/time.cal.mwdlast/time.cal.mwdlast.nonmembers/streaming.pass.cpp FAIL
std/utilities/time/time.cal/time.cal.wdidx/time.cal.wdidx.nonmembers/streaming.pass.cpp FAIL
std/utilities/time/time.cal/time.cal.wdlast/time.cal.wdlast.nonmembers/streaming.pass.cpp FAIL
std/utilities/time/time.cal/time.cal.weekday/time.cal.weekday.nonmembers/streaming.pass.cpp FAIL
std/utilities/time/time.cal/time.cal.ymwd/time.cal.ymwd.nonmembers/streaming.pass.cpp FAIL
std/utilities/time/time.cal/time.cal.ymwdlast/time.cal.ymwdlast.nonmembers/streaming.pass.cpp FAIL

Expand Down Expand Up @@ -878,6 +875,9 @@ std/utilities/time/time.cal/time.cal.day/time.cal.day.nonmembers/streaming.pass.
std/utilities/time/time.cal/time.cal.md/time.cal.md.nonmembers/streaming.pass.cpp SKIPPED
std/utilities/time/time.cal/time.cal.mdlast/streaming.pass.cpp SKIPPED
std/utilities/time/time.cal/time.cal.month/time.cal.month.nonmembers/streaming.pass.cpp SKIPPED
std/utilities/time/time.cal/time.cal.mwd/time.cal.mwd.nonmembers/streaming.pass.cpp SKIPPED
std/utilities/time/time.cal/time.cal.wdlast/time.cal.wdlast.nonmembers/streaming.pass.cpp SKIPPED
std/utilities/time/time.cal/time.cal.weekday/time.cal.weekday.nonmembers/streaming.pass.cpp SKIPPED
std/utilities/time/time.cal/time.cal.year/time.cal.year.nonmembers/streaming.pass.cpp SKIPPED
std/utilities/time/time.cal/time.cal.ym/time.cal.ym.nonmembers/streaming.pass.cpp SKIPPED
std/utilities/time/time.cal/time.cal.ymd/time.cal.ymd.nonmembers/streaming.pass.cpp SKIPPED
Expand Down
3 changes: 0 additions & 3 deletions tests/libcxx/skipped_tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,8 @@ utilities\memory\default.allocator\allocator.members\allocate.verify.cpp

# *** MISSING STL FEATURES ***
# C++20 P0355R7 "<chrono> Calendars And Time Zones"
utilities\time\time.cal\time.cal.mwd\time.cal.mwd.nonmembers\streaming.pass.cpp
utilities\time\time.cal\time.cal.mwdlast\time.cal.mwdlast.nonmembers\streaming.pass.cpp
utilities\time\time.cal\time.cal.wdidx\time.cal.wdidx.nonmembers\streaming.pass.cpp
utilities\time\time.cal\time.cal.wdlast\time.cal.wdlast.nonmembers\streaming.pass.cpp
utilities\time\time.cal\time.cal.weekday\time.cal.weekday.nonmembers\streaming.pass.cpp
utilities\time\time.cal\time.cal.ymwd\time.cal.ymwd.nonmembers\streaming.pass.cpp
utilities\time\time.cal\time.cal.ymwdlast\time.cal.ymwdlast.nonmembers\streaming.pass.cpp

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,34 @@ void test_year_formatter() {
stream_helper(STR("-32768 is not a valid year"), year{-32768});
}

template <typename CharT>
void test_weekday_formatter() {
weekday invalid{10};
assert(format(STR("{}"), weekday{3}) == STR("Wed"));
stream_helper(STR("Wed"), weekday{3});
stream_helper(STR("10 is not a valid weekday"), invalid);

assert(format(STR("{:%a %A}"), weekday{6}) == STR("Sat Saturday"));
assert(format(STR("{:%u %w}"), weekday{6}) == STR("6 6"));
assert(format(STR("{:%u %w}"), weekday{0}) == STR("7 0"));
}

template <typename CharT>
void test_weekday_indexed_formatter() {
weekday_indexed invalid1{Tuesday, 10};
weekday_indexed invalid2{weekday{10}, 3};
weekday_indexed invalid3{weekday{14}, 9};
assert(format(STR("{}"), weekday_indexed{Monday, 1}) == STR("Mon[1]"));
stream_helper(STR("Mon[1]"), weekday_indexed{Monday, 1});
stream_helper(STR("Tue[10 is not a valid index]"), invalid1);
stream_helper(STR("10 is not a valid weekday[3]"), invalid2);
stream_helper(STR("14 is not a valid weekday[9 is not a valid index]"), invalid3);

assert(format(STR("{:%a %A}"), weekday_indexed{Monday, 2}) == STR("Mon Monday"));
assert(format(STR("{:%u %w}"), weekday_indexed{Tuesday, 3}) == STR("2 2"));
assert(format(STR("{:%u %w}"), weekday_indexed{Sunday, 4}) == STR("7 0"));
}

template <typename CharT>
void test_year_month_day_formatter() {
year_month_day invalid{year{1234}, month{0}, day{31}};
Expand Down Expand Up @@ -460,6 +488,12 @@ int main() {
test_year_formatter<char>();
test_year_formatter<wchar_t>();

test_weekday_formatter<char>();
test_weekday_formatter<wchar_t>();

test_weekday_indexed_formatter<char>();
test_weekday_indexed_formatter<wchar_t>();

test_year_month_day_formatter<char>();
test_year_month_day_formatter<wchar_t>();

Expand Down