mirror of
https://github.com/HowardHinnant/date.git
synced 2024-12-26 07:53:16 +08:00
Range check minutes under parse
This commit is contained in:
parent
ca4036a4b0
commit
43d8a4eab0
@ -7006,7 +7006,8 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
goto broken;
|
||||
}
|
||||
fds.ymd = ymd;
|
||||
fds.tod = time_of_day<Duration>(hours{h} + minutes{min});
|
||||
fds.tod = time_of_day<Duration>{h};
|
||||
fds.tod.m_ = min;
|
||||
fds.tod.s_ = detail::decimal_format_seconds<Duration>{s};
|
||||
if (wd != not_a_weekday)
|
||||
fds.wd = weekday{static_cast<unsigned>(wd)};
|
||||
|
@ -360,6 +360,12 @@ test_d()
|
||||
assert(!in.bad());
|
||||
assert(tp == 2016_y/12/9);
|
||||
}
|
||||
{
|
||||
std::istringstream in{"2016 31 11"};
|
||||
sys_days tp;
|
||||
in >> parse("%Y %e %m", tp);
|
||||
assert(in.fail());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -413,6 +419,12 @@ test_H()
|
||||
assert(!in.bad());
|
||||
assert(tp == sys_days{2016_y/12/11} + hours{15});
|
||||
}
|
||||
{
|
||||
std::istringstream in{"2016-12-11 24"};
|
||||
sys_time<hours> tp;
|
||||
in >> parse("%F %H", tp);
|
||||
assert(in.fail());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -436,6 +448,12 @@ test_Ip()
|
||||
assert(!in.bad());
|
||||
assert(tp == sys_days{2016_y/12/11} + hours{1});
|
||||
}
|
||||
{
|
||||
std::istringstream in{"2016-12-11 13 am"};
|
||||
sys_time<hours> tp;
|
||||
in >> parse("%F %I %p", tp);
|
||||
assert(in.fail());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -474,6 +492,12 @@ test_m()
|
||||
assert(!in.bad());
|
||||
assert(tp == 2016_y/9/12);
|
||||
}
|
||||
{
|
||||
std::istringstream in{"2016 12 13"};
|
||||
sys_days tp;
|
||||
in >> parse("%Y %d %m", tp);
|
||||
assert(in.fail());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -489,6 +513,12 @@ test_M()
|
||||
assert(!in.bad());
|
||||
assert(tp == sys_days{2016_y/12/11} + minutes{15});
|
||||
}
|
||||
{
|
||||
std::istringstream in{"2016-12-11 65"};
|
||||
sys_time<minutes> tp;
|
||||
in >> parse("%F %M", tp);
|
||||
assert(in.fail());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -512,6 +542,12 @@ test_S()
|
||||
assert(!in.bad());
|
||||
assert(tp == sys_days{2016_y/12/11} + seconds{15} + milliseconds{1});
|
||||
}
|
||||
{
|
||||
std::istringstream in{"2016-12-11 60"};
|
||||
sys_seconds tp;
|
||||
in >> parse("%F %S", tp);
|
||||
assert(in.fail());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -552,6 +588,24 @@ test_T()
|
||||
assert(!in.bad());
|
||||
assert(d == hours{15} + minutes{43} + seconds{22} + milliseconds{1});
|
||||
}
|
||||
{
|
||||
std::istringstream in{"2016-12-11 24:43:22"};
|
||||
sys_seconds tp;
|
||||
in >> parse("%F %T", tp);
|
||||
assert(in.fail());
|
||||
}
|
||||
{
|
||||
std::istringstream in{"2016-12-11 15:60:22"};
|
||||
sys_seconds tp;
|
||||
in >> parse("%F %T", tp);
|
||||
assert(in.fail());
|
||||
}
|
||||
{
|
||||
std::istringstream in{"2016-12-11 15:43:60"};
|
||||
sys_seconds tp;
|
||||
in >> parse("%F %T", tp);
|
||||
assert(in.fail());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
x
Reference in New Issue
Block a user