[libcxx] Reject month 0 in get_date/__get_month
[libcxx] Reject month 0 in get_date/__get_month This fixes #47663. Months in dates should be >= 1 and <= 12. We parse up to two digits then minus one, because we want to store this as "months since January" (0-11). However we didn't check that the result of that was not -1. For example if you had (MM/DD/YYYY) 00/21/2022. Added tests for: * Failing if month is 0 * Failing if month is 13 * Allowing a leading zero in month e.g. "01" Note that libc++ and libstdc++ return different values on parsing failure, and MSVC STL returns end of stream instead. Handle the first two by checking for defines, MSVC STL expects these tests to fail for other reasons already: https://github.com/microsoft/STL/blob/main/tests/libcxx/expected_results.txt#L372 so not handling that case here. Reviewed By: #libc, Mordante Differential Revision: https://reviews.llvm.org/D124175
Loading
Please sign in to comment