Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why c++ standard support function strftime but not strptime?

Why C++ standard support function strftime() but not strptime()? strftime() is available to change a time to string, but there isn't a function which can change a string back to time.

On Posix strptime() is available as a C-like function, using it need to take care of the potential problem of mixed C and C++ code.

like image 615
songyuanyao Avatar asked Feb 14 '14 10:02

songyuanyao


1 Answers

I'm not a part of the standards committee, but here goes:

strptime is defined by the ISO/IEC 9945 documents (essentially the Single Unix Specification / POSIX). It is not part of the 9899:1990 or 9899:1999 C standards documents (and I don't think it is part of 9899:2011, though I can't be sure as I don't have that one in my possession yet).

Since the C++ standards only mandate levels of compatibility with their C cousin, you won't find strptime mandated by the 14882:1998 or 14882:2011 C++ standards documents.

like image 111
CasaDeRobison Avatar answered Sep 29 '22 07:09

CasaDeRobison