Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CString to CTime

362 views
Skip to first unread message

Lauren King

unread,
May 21, 1999, 3:00:00 AM5/21/99
to

Hi:

Trying to get a Cstring converted to a Ctime. I recieve the CString in the following format....
12:00pm or 23:00

Lauren

-----------------** -- Posted from CodeGuru -- **-----------------
http://www.codeguru.com/ The website for Visual C++ programmers.


Joshua Yang

unread,
May 21, 1999, 3:00:00 AM5/21/99
to
// Using the 23:00 format,
CString sHour = CYourString.Left(2);
CString sMinute = CYourString.Right(2);

CTime time(1999, 5, 21, atoi(sHour), atoi(sMinute), 0);

David Lowndes

unread,
May 22, 1999, 3:00:00 AM5/22/99
to
>Trying to get a Cstring converted to a Ctime. I recieve the CString in the following format....
>12:00pm or 23:00

Lauren,

I think you can use COleDateTime::ParseDateTime to convert the string
to a COleDateTime, then use COleDateTime::GetAsSystemTime to convert
to a SYSTEMTIME. Finally you can construct a CTime object from the
SYSTEMTIME.

Dave
----
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.

Peter Ent

unread,
May 24, 1999, 3:00:00 AM5/24/99
to
COleDateTime has a parse method that takes a string and converts it. It is a COleDateTime, not a
CTime, but it is more robust than CTime.

Lauren King wrote:

> Hi:


>
> Trying to get a Cstring converted to a Ctime. I recieve the CString in the following format....
> 12:00pm or 23:00
>

0 new messages