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
1 change: 0 additions & 1 deletion stl/inc/chrono
Original file line number Diff line number Diff line change
Expand Up @@ -4145,7 +4145,6 @@ namespace chrono {
_NODISCARD bool _Make_duration(duration<_Rep, _Period>& _Duration_result) {
const bool _Consistent = _Calculate_hour24();
if (_Consistent) {
_Duration_result = duration<_Rep, _Period>::zero(); // TRANSITION: LWG-3536 & GH-1740
return _Apply_duration_fields<_Parse_tp_or_duration::_Duration>(_Duration_result);
}

Expand Down
24 changes: 24 additions & 0 deletions tests/std/tests/P0355R7_calendars_and_time_zones_io/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,29 @@ void test_limits(const char* flag, const IntType min, const IntType max) {
assert(value == TimeType{max});
}

void test_lwg_3536() {
// LWG-3536, "Should chrono::from_stream() assign zero to duration for failure?"
minutes mm{20};

{
istringstream iss{"2:2:30"};
iss >> parse(string{"%H:%M:%S"}, mm);
assert(iss.fail() && mm == 20min);
}

{
istringstream iss{"June"};
iss >> parse(string{"%B"}, mm);
assert(iss.fail() && mm == 20min);
}

{
istringstream iss{""};
iss >> parse(string{"%B"}, mm);
assert(iss.fail() && mm == 20min);
}
}

void parse_seconds() {
seconds time;
test_parse("1", "%S", time);
Expand Down Expand Up @@ -1182,6 +1205,7 @@ void parse_wchar() {
}

void test_parse() {
test_lwg_3536();
parse_seconds();
parse_minutes();
parse_hours();
Expand Down