diff --git a/FAQ.md b/FAQ.md index bbeb152..55e8717 100644 --- a/FAQ.md +++ b/FAQ.md @@ -1,5 +1,6 @@ ## Contents - [Why can't I do day arithmetic on a `year_month_day`?](#day_arithmetic) +- [Why is `%A` failing?](#week_day_parse_bug) - [Why is `local_t` not a proper clock?](#local_t) *** @@ -58,6 +59,33 @@ It would be very easy to add `T& list::operator[](size_t index)`. But that w This library continues in that tradition: The expensive operations are not hidden. + +### Why is `%A` failing? + +This program is supposed to work: + +```c++ +#include "date/date.h" +#include +#include + +int +main() +{ + using namespace date; + std::istringstream in{"Sun 2016-12-11"}; + sys_days tp; + in >> parse("%A %F", tp); + std::cout << tp << '\n'; +} +``` + +But for me it outputs `1970-01-01` and `in.fail()` is true. + +_Answer:_ This is a bug in your std::lib `std::time_get` facet. It _should_ use both `%a` and `%A` identically, and these should both parse either the abbreviated or full `week_day` name in a case-insensitive manner. Unfortunately some implementations won't do that, resulting in this failure. These same implementations have the same bug with `%b` and `%B` (month names). + +You can work around this bug by compiling with `-DONLY_C_LOCALE`. This flag restricts you to the "C" locale, but it also avoids use of your `std::time_get` and `std::time_put` facets, instead implementing that logic within this library. + ### Why is `local_t` not a proper clock?