How to format a CTime object
-
there is a string represent time like this:
Mon, 17 Dec 2007 08:36:48
How can I format this string into a CTime object or some other internal time structure? I've written a function to translate this string into a CTime, but I still wonder is there some library function can do this for me? Thank you! :)A Chinese VC++ programmer
modified on Tuesday, January 15, 2008 3:43:55 AM
-
there is a string represent time like this:
Mon, 17 Dec 2007 08:36:48
How can I format this string into a CTime object or some other internal time structure? I've written a function to translate this string into a CTime, but I still wonder is there some library function can do this for me? Thank you! :)A Chinese VC++ programmer
modified on Tuesday, January 15, 2008 3:43:55 AM
See here[^] for low level time string formatting stuff. To go the other way you'll probably have to roll your own based on sscanf, shouldn't be difficult as long as you're only accepting a well known fixed input format, otherwise you're going to need a parser and that's more complex.
Nothing is exactly what it seems but everything with seems can be unpicked.
-
there is a string represent time like this:
Mon, 17 Dec 2007 08:36:48
How can I format this string into a CTime object or some other internal time structure? I've written a function to translate this string into a CTime, but I still wonder is there some library function can do this for me? Thank you! :)A Chinese VC++ programmer
modified on Tuesday, January 15, 2008 3:43:55 AM
Try this COleDateTime class to format the Time/Date. i think this will help you.
-
Try this COleDateTime class to format the Time/Date. i think this will help you.
And it can also parse a string representing time. Good hit, indeed. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
[my articles] -
See here[^] for low level time string formatting stuff. To go the other way you'll probably have to roll your own based on sscanf, shouldn't be difficult as long as you're only accepting a well known fixed input format, otherwise you're going to need a parser and that's more complex.
Nothing is exactly what it seems but everything with seems can be unpicked.
Yes, my own code is based on sscanf, and the string format is fixed like the sample above.
strftime, wcsftime, _strftime_l, _wcsftime_l
these functions format tm to string, but what I want is formating string to tm or CTime object. Thanks! :)A Chinese VC++ programmer