FIX: COleDateTime::SetDate no longer returns an "Invalid" status on an incorrect date in Visual C++ .NET

Article translations Article translations
Article ID: 813647 - View products that this article applies to.
This article has been archived. It is offered "as is" and will no longer be updated.
CPR - VS .NET - Hotfix in SP1
Expand all | Collapse all

On This Page

SYMPTOMS

The behavior of the Microsoft Foundation Classes (MFC) and the Active Template Library (ATL) method COleDateTime::SetDate changed in Microsoft Visual C++ .NET. In the .NET version, when you type an incorrect date, the object status no longer sets a status of invalid. Instead, the object status converts the date to the nearest valid value. This may result in unexpected behavior for applications that depend on the invalid status of the COleDateTime object. The behavior is different from the Microsoft Developer Network (MSDN) information that shipped with .NET version of the Visual C++ .NET libraries.

RESOLUTION

Service pack information

To resolve this problem, obtain the latest service pack for Microsoft Visual Studio .NET. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
837234 List of bugs that are fixed in Visual Studio .NET 2002 Service Pack 1

Hotfix information

The English version of this fix has the file attributes (or later) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.
   Date         Time  Version               Size  File name     
 ---------------------------------------------------------------
 24-Jan-2003  02:06                  2,011,136  Atl70.pdb
 12-Sep-2002  16:50                     39,733  afxdao.h
 24-Jan-2003  02:06  7.0.9660.0         84,992  atl70.dll
 23-Jul-2002  20:08                      3,443  atlbase.cpp
 23-Jul-2002  20:08                    163,480  atlbase.h
 20-Jan-2003  20:07                     16,396  atlcomtime.inl
 23-Jul-2002  20:08                     15,521  atlcore.h
 23-Jul-2002  20:08                     43,105  atlimage.h
 24-Jan-2003  02:06                     48,090  atlmincrt.lib
 24-Jan-2003  02:06                    659,456  atlmincrt.pdb
 24-Jan-2003  02:06                  1,003,890  atlsd.lib
 24-Jan-2003  02:06                  1,306,624  atlsd.pdb
 24-Jan-2003  02:06                    934,264  atls.lib
 24-Jan-2003  02:06                  1,306,624  atls.pdb
 24-Jan-2003  02:06                     14,546  atl.lib
 11-Nov-2002  22:45                     63,284  cstringt.h
 05-Dec-2002  20:21                    116,779  dbcore.cpp
 12-Sep-2002  16:50                     19,956  makefile
 24-Jan-2003  03:36  7.0.9660.0         40,960  mfc70chs.dll
 24-Jan-2003  03:36  7.0.9660.0         45,056  mfc70cht.dll
 24-Jan-2003  03:36  7.0.9660.0         61,440  mfc70deu.dll
 24-Jan-2003  03:22                    527,756  mfc70d.def
 24-Jan-2003  03:23                  3,066,694  mfc70d.lib
 24-Jan-2003  03:36  7.0.9660.0         57,344  mfc70enu.dll
 24-Jan-2003  03:36  7.0.9660.0         61,440  mfc70esp.dll
 24-Jan-2003  03:36  7.0.9660.0         61,440  mfc70fra.dll
 24-Jan-2003  03:36  7.0.9660.0         61,440  mfc70ita.dll
 24-Jan-2003  03:36  7.0.9660.0         49,152  mfc70jpn.dll
 24-Jan-2003  03:36  7.0.9660.0         49,152  mfc70kor.dll
 24-Jan-2003  03:24                    528,736  mfc70ud.def
 24-Jan-2003  03:25  7.0.9660.0      2,066,944  mfc70ud.dll
 24-Jan-2003  03:27                  3,978,842  mfc70ud.lib
 24-Jan-2003  03:43                    393,034  mfc70u.def
 24-Jan-2003  03:57  7.0.9660.0      1,016,832  mfc70u.dll
 24-Jan-2003  03:29                  3,042,324  mfc70u.lib
 24-Jan-2003  03:42                    392,265  mfc70.def
 24-Jan-2003  04:07  7.0.9660.0      1,028,096  mfc70.dll
 24-Jan-2003  03:24                  2,287,020  mfc70.lib
 12-Sep-2002  16:50                      7,662  mfcdll.mak
 24-Jan-2003  03:23                    526,960  mfcs70d.lib
 24-Jan-2003  03:25                    468,956  mfcs70ud.lib
 24-Jan-2003  03:44                    452,554  mfcs70u.lib
 24-Jan-2003  03:43                    505,780  mfcs70.lib
 24-Jan-2003  03:36                 10,513,408  mfc.bsc
 24-Jan-2003  03:18                 16,598,882  nafxcwd.lib
 24-Jan-2003  03:17                  2,093,056  nafxcwd.pdb
 24-Jan-2003  03:19                 16,468,250  nafxcw.lib
 24-Jan-2003  03:18                  2,068,480  nafxcw.pdb
 20-Sep-2002  00:18                     44,958  oledisp1.cpp
 24-Jan-2003  03:21                 17,032,292  uafxcwd.lib
 24-Jan-2003  03:20                  2,093,056  uafxcwd.pdb
 24-Jan-2003  03:22                 16,743,760  uafxcw.lib
 24-Jan-2003  03:21                  2,068,480  uafxcw.pdb
 05-Nov-2002  18:40                     34,858  viewprev.cpp
 24-Jan-2003  03:23  7.0.9660.0      2,072,576  Mfc70d.dll
 24-Jan-2003  03:23                  1,791,934  Mfc70d.map
 24-Jan-2003  03:23                  7,875,584  Mfc70d.pdb
 24-Jan-2003  03:25                  1,842,070  Mfc70ud.map
 24-Jan-2003  03:25                  7,908,352  Mfc70ud.pdb
 24-Jan-2003  03:57                  9,964,544  Mfc70u.pdb
 24-Jan-2003  04:07                  1,149,706  Mfc70.map
 24-Jan-2003  04:07                  9,980,928  Mfc70.pdb
 24-Jan-2003  03:23                  1,888,256  Mfcs70d.pdb
 24-Jan-2003  03:25                  1,896,448  Mfcs70ud.pdb
 24-Jan-2003  03:44                  1,888,256  Mfcs70u.pdb
 24-Jan-2003  03:43                  1,880,064  Mfcs70.pdb
				

MORE INFORMATION

The observed behavior occurs because of a change in the implementation of COleDateTime. The new implementation uses SystemTimeToVariantTime function to convert the value that is supplied to the COleDateTime object.

Visit the following Microsoft Developer Network Web site for more information about SystemTimeToVariantTime function:
http://msdn2.microsoft.com/fr-fr/library/ms221646.aspx
The SystemTimeToVariantTime function accepts invalid dates and then tries to fix them when resolving to a VARIANT time. For example, an invalid date such as 2/29/2001 will resolve to 3/1/2001. However, the Visual Studio .NET 2002 MSDN entry for COleDateTime::SetDate states that an invalid (1) state would be set for the object.


The following code replicates the problem:

COleDateTime dtDate;
CString	szDate;
BOOL bOK;

bOK = dtDate.SetDate(2003, 2, 29);
if((bOK == 0) && (dtDate.GetStatus() == COleDateTime::valid))
{
	szDate = dtDate.Format();
	AfxMessageBox(szDate);
}
Note You may have to recompile your code after you apply this fix.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This problem was first corrected in Visual Studio .NET 2002 Service Pack 1.

Properties

Article ID: 813647 - Last Review: October 26, 2013 - Revision: 2.2
APPLIES TO
  • Microsoft Visual Studio .NET 2002 Academic Edition
  • Microsoft Visual Studio .NET 2002 Enterprise Architect
  • Microsoft Visual Studio .NET 2002 Enterprise Developer
  • Microsoft Visual Studio .NET 2002 Professional Edition
Keywords: 
kbnosurvey kbarchive kbhotfixserver kbqfe kbvs2002sp1sweep kbvs2002sp1fix kbfix kbbug KB813647

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com