// pick up date from string\r
try\r
{\r
- CTime tm(_wtoi(input.Mid(0,4)),\r
+ COleDateTime tm(_wtoi(input.Mid(0,4)),\r
_wtoi(input.Mid(5,2)),\r
_wtoi(input.Mid(8,2)),\r
_wtoi(input.Mid(11,2)),\r
_wtoi(input.Mid(14,2)),\r
- _wtoi(input.Mid(17,2)),\r
- 0);\r
- if(tm.GetTime()<=1)\r
+ _wtoi(input.Mid(17,2)));\r
+ if( tm.GetStatus() != COleDateTime::valid )\r
return CTime();//Error parsing time-string\r
\r
// pick up utc offset\r
CString sign = input.Mid(20,1); // + or -\r
int hoursOffset = _wtoi(input.Mid(21,2));\r
int minsOffset = _wtoi(input.Mid(23,2));\r
+ // convert to a fraction of a day\r
+ double offset = (hoursOffset*60 + minsOffset) / 1440.0; // 1440 mins = 1 day\r
if ( sign == "-" )\r
{\r
- hoursOffset = -hoursOffset;\r
- minsOffset = -minsOffset;\r
+ offset = -offset;\r
}\r
- // make a timespan object with this value\r
- CTimeSpan offset( 0, hoursOffset, minsOffset, 0 );\r
// we have to subtract this from the time given to get UTC\r
tm -= offset;\r
- // get local timezone\r
+ // get utc time as a SYSTEMTIME\r
SYSTEMTIME sysTime;\r
tm.GetAsSystemTime( sysTime );\r
+ // and convert to users local time\r
SYSTEMTIME local;\r
if ( SystemTimeToTzSpecificLocalTime( &m_TimeZone, &sysTime, &local ) )\r
{\r
}\r
else\r
{\r
- ASSERT(false);\r
+ ASSERT(false); // this should not happen but leave time in utc if it does\r
}\r
- tm = CTime( sysTime, 0 );\r
- return tm;\r
+ // convert to CTime and return\r
+ return CTime( sysTime, -1 );;\r
}\r
catch(CException* e)\r
{\r