Reverse of 'ctime' function

Started by
2 comments, last by Kylotan 21 years, 1 month ago
Just as ctime takes a time_t and returns a char*, is there an equivalent function anywhere that will take a char* that is supposedly the output of a time_t, and return the appropriate time_t? I''d think there''d be something like this in a mail package, but I''ve not found one yet. There seems to be a ''strptime'' in some implementations which returns a ''struct tm'' that I could probably use, but does anyone have anything better? I am aware there may be locale issues here, too. [ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files | My stuff ]
Advertisement
You have the std::time_get facet class in the <locale> header.

[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Hmm, might be useful. I''d prefer something in C but I may be able to use that instead, so thanks.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files | My stuff ]
If you''re not too averse to using strptime (locale issues aside) to get a struct tm*, then you can use mktime to get a time_t out of that.

- dorix

This topic is closed to new replies.

Advertisement