Are there any functions available to parse an RFC3339 date in C++ (even if they are Win32 specific)? I was previously using Qt and the QDateTime::fromString() function to parse the date but I am now using plain old Win32 C++ (No MFC) and I'm struggling to find a way to do it. If there is no standard in way I can write my own but just in case I missed something...
Asked
Active
Viewed 1,971 times
2 Answers
1
For parsing and comparing RFC3339 formated dates, you can use Howard Hinnant's date library.
It can be used as followed:
#include "date/date.h"
#include <iostream>
#include <sstream>
int main()
{
using namespace date;
std::istringstream infile{"2005-08-15T15:52:01+04:00"};
sys_seconds tp; // This is a system_clock time_point with seconds precision
infile >> parse("%FT%T%Ez", tp);
std::cout << tp.time_since_epoch() << " is " << tp << '\n';
}
A slightly modified versions of "date.h" and "tz.h" were voted into the C++20 working draft.

Trevor Hickey
- 36,288
- 32
- 162
- 271
0
I'm not aware of any standard api - atleast on windows. I think you'll have to write your own ...

obelix
- 986
- 8
- 14
-
Yeah, it's certainly looking that way, never mind, shouldn't be too challenging... – JWood Jun 22 '10 at 09:38
-
This is related to http://stackoverflow.com/questions/234171/parse-a-date-from-a-string-in-win32 . – Reinderien Jun 22 '10 at 20:40