Parsing string with Time Zone info
-
I tried using COleDateTime::ParseDateTime(...) and VarDateFromStr(...) to parse a date/time string that contains *time zone* information (ET, CT, +4:00, GMT+4:00, etc...) but every time I do so I get "Invalid DateTime" // code ////////////////////// COleDateTime dt; CString sdate = "Feb 1 2002 17:05 +7:00"; // <- Time Zone string date dt.ParseDateTime(sdate); CString st2 = dt.Format("%H:%M"); // <- returns 'Invalid DateTime' // ----------------------------- Is it just me (am I doing this wrong) or the ParseDateTime is no good for time zones? Is there any other way/method that could parse string with time zone information (like: "Feb 1 2002 17:05 +7:00"). JScript and VC#.NET have no problem parsing date/time strings with time zone info, but I can't seem to parse date/time string in VC++. :( Platform: WinXP Pro, VC++.NET (unmanaged) Thanks in advance Mike
-
I tried using COleDateTime::ParseDateTime(...) and VarDateFromStr(...) to parse a date/time string that contains *time zone* information (ET, CT, +4:00, GMT+4:00, etc...) but every time I do so I get "Invalid DateTime" // code ////////////////////// COleDateTime dt; CString sdate = "Feb 1 2002 17:05 +7:00"; // <- Time Zone string date dt.ParseDateTime(sdate); CString st2 = dt.Format("%H:%M"); // <- returns 'Invalid DateTime' // ----------------------------- Is it just me (am I doing this wrong) or the ParseDateTime is no good for time zones? Is there any other way/method that could parse string with time zone information (like: "Feb 1 2002 17:05 +7:00"). JScript and VC#.NET have no problem parsing date/time strings with time zone info, but I can't seem to parse date/time string in VC++. :( Platform: WinXP Pro, VC++.NET (unmanaged) Thanks in advance Mike
From Visual C++ .NET documentation:
Remarks
If the string was successfully converted to a date/time value, the value of this COleDateTime object is set to that value and its status to valid.Note Year values must lie between 100 and 9999, inclusively.
The lpszDate parameter can take a variety of formats. For example, the following strings contain acceptable date/time formats:"25 January 1996"
"8:30:00"
"20:30:00"
"January 25, 1996 8:30:00"
"8:30:00 Jan. 25, 1996"
"1/25/1996 8:30:00" // always specify the full year,
// even in a 'short date' formatSeems odd but you can't get it from ParseDateTime -:suss:Matt Newman:suss: -Sonork ID: 100.11179:BestSnowman
†