BUG: CTime class methods return an incorrect date for some time zones for Windows CE Version 2.11 (240940)
The information in this article applies to:
- The Microsoft Foundation Classes (MFC), when used with:
- Microsoft Windows CE Toolkit for Visual C++ 6.0
- Microsoft Windows CE Operating System, Versions 2.11
This article was previously published under Q240940 SYMPTOMS
The following code returns an incorrect date when the time zone is set to a non-United States time, such as Singapore, Australia, Japan, or England:
CTime ctCur = CTime::GetCurrentTime();
CString csMsg;
csMsg.Format(_T("%d / %d / %d"), ctCur.GetYear(), ctCur.GetMonth() , ctCur.GetDay());
AfxMessageBox(csMsg);
This behavior occurs only on devices running Windows CE version 2.11. This behavior cannot be reproduced on the emulation or earlier versions of Windows CE 2.0 or 2.01.
CAUSE
The data type (time_t) of the wce_GetTZBias() function's parameter pTZBiasSecs is not correct. The date type (time_t) is defined as "unsigned long". However, *pTZBiasSec can be negative. For example, if Beijing time is GMT-8, *pTZBiasSec should be -8*60*60.
static void wce_GetTZBias(time_t* pTZBiasSecs = NULL, int* pDSTBiasSecs = NULL)
Thus, when the set time zone has a negative BiasSec, wce_GetTZBias returns a large number for pTZBiasSecs. Because it changed a negative int to an unsigned int, the wrong Date is returned for some time zones when calling CTime::GetCurrentTime or CTime::GetYear.
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.
Modification Type: | Minor | Last Reviewed: | 3/9/2006 |
---|
Keywords: | kbBug kbLocalization kbpending KB240940 |
---|
|