Stupid C question

This question seems so easy I feel dumb for asking, but I can't find the answer after much searching. Does anyone know of a C api call on Windows to parse a text string that contains a date and/or time (ex "12/18/2004 12:00 pm") into a time_t structure, or some other structure that can be converted into a time_t?

It's not that hard to parse out a date time of a fixed format, but this is for Fabric I want this to be able to accept a variety of the most common formats. I found some stuff for MFC and some other frameworks, but they are too heavy to add to project, this must exist on Windows as a core API call, right?

If I can't find it, I'll guess I'll use the Boost C++ libraries, which have pretty comprehensive date time support. But its a huge framework and I'd rather not take a bunch of time integrating into my project.

Posted January 23, 2006 5:10 PM

Comments

Not sure about Windows APIs but you ought to take a look at ICU http://www-306.ibm.com/software/globalization/icu/index.jsp

It's a bit large but if you're going to do any sort of i18n work, it will be worthwhile.

Bob, January 23, 2006 6:37 PM

Windows API call? That'll surely make it tough to make it platform portable!

Brendon Upson, January 23, 2006 8:12 PM

Thanks for the ICU link Bob, I didn't know about that. It seems to have some other stuff I might need in the future.

I don't mind using a Windows API call for now. If it comes time to port to another platform, then I'll worry about a replacement call, but for now I just want to get it all feature complete.

Damien, January 23, 2006 8:27 PM

The ICU stuff is comprehensive. Eventually you'll probably need more than just date/time parsing. We used ICU4J on Workplace. I believe that Notes/Domino started using ICU in R6.

The license is pretty liberal. According to the web site, ICU is licensed under the X License which is compatible with GPL but non-copyleft.

Bob, January 24, 2006 2:45 AM

Post a comment




Remember Me?

(you may use HTML tags for style)