Reputation: 47243
I am using a library which delegates date formatting to Boost Date Time Input/Output, and i need to parse dates which look like "January 2nd, 2024".
The month and the year are easy enough, as are the spaces and comma.
The format specifier %e
parses a day of the month, and copes with one or two digits, without requiring a leading zero or space. But it will apparently not trailing ordinal characters. I tried parsing the string
January 2nd, 2024
Using:
%B %e, %Y
And it comes out with a gibberish value.
Is there a way to parse dates like this? I would happily ignore the exact characters in the ordinal suffix, and so treat strings like:
January 2th, 2024
As valid.
Upvotes: 0
Views: 35