DetailPage-MSS-KB

Microsoft small business knowledge base

Article ID: 214661 - Last Review: February 21, 2014 - Revision: 2.4

Hotfix Download Available
View and request hotfix downloads
 
This article was previously published under Q214661
This article has been archived. It is offered "as is" and will no longer be updated.

On This Page

SYMPTOMS

The C-Run-time Library date/time functions might fail to calculate the correct time during the first week of daylight saving time beginning April 1, 2001. The bug corrects itself after one week, on the following Sunday. This bug is not related to the year 2000 problem.

CAUSE

The bug is caused by a logic error in the C-Run-time library's cvtdate helper function.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug was corrected in Visual Studio 6.0 Service Pack 3. For more information about Visual Studio service packs, please see the following articles in the Microsoft Knowledge Base:

194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why  (http://support.microsoft.com/kb/194022/EN-US/ )

194295 HOWTO: Tell That Visual Studio 6.0 Service Packs Are Installed  (http://support.microsoft.com/kb/194295/EN-US/ )

MORE INFORMATION

Steps to Reproduce Behavior

The following sample program reproduces the problem:

// ----------------- start of sample program -------------------------

// Compiler switches needed : none.

#include <time.h>;
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>

int main ()
{
    struct tm ltm;
    time_t tstamp = 0;

    ltm.tm_year = 90;	/* First valid year .*/ 
    ltm.tm_mon = 3;		/* April. */ 
    ltm.tm_mday = 1;	/* 1st of the month. */ 
    ltm.tm_hour = 3;	/* At 3:00 am. */ 
    ltm.tm_min = 0;
    ltm.tm_sec = 0;
    ltm.tm_wday =0;
    ltm.tm_yday = 0;

    while (ltm.tm_year <= 2005)
    {
        ltm.tm_isdst = -1;

	// mktime indirectly calls cvtdate which has the logic bug.
	tstamp = mktime(&ltm);

	/* If it's Sunday April 1st, it should also be DST */ 
	if (!ltm.tm_wday && !ltm.tm_isdst)
	{
	    printf("April 01 is the first Sunday in April, %d  \ 
            -it should be DST but tm_isdst says it's \ 
            not!\n", 1900+ltm.tm_year);
	    while (!ltm.tm_isdst)
	    {
		ltm.tm_mday++;
		ltm.tm_isdst=-1;
		tstamp = mktime(&ltm);
	    }
	    printf("\tDST is reported as starting on  \ 
            %d/%d/%d\n", 1+ltm.tm_mon, ltm.tm_mday, \ 
	    1900+ltm.tm_year);
	
            ltm.tm_mday = 1;
	}
	
        ltm.tm_year++;
	
    }

    return 0;
}


// ----------------- end  of sample program ---------------------------
				

REFERENCES

http://msdn.microsoft.com/en-us/visualc/default.aspx (http://msdn.microsoft.com/en-us/visualc/default.aspx)

APPLIES TO
  • Microsoft Visual C++ 4.1 Subscription
  • Microsoft Visual C++ 4.2 Enterprise Edition
  • Microsoft Visual C++ 5.0 Enterprise Edition
  • Microsoft Visual C++ 6.0 Enterprise Edition
  • Microsoft Visual C++ 4.2 Professional Edition
  • Microsoft Visual C++ 5.0 Professional Edition
  • Microsoft Visual C++ 6.0 Professional Edition
  • Microsoft Visual C++, 32-bit Learning Edition 6.0
Keywords: 
kbnosurvey kbarchive kbhotfixserver kbqfe kbbug kbcrt kbfix kbvs600sp3fix KB214661
Share
Additional support options
Ask The Microsoft Small Business Support Community
Contact Microsoft Small Business Support
Find Microsoft Small Business Support Certified Partner
Find a Microsoft Store For In-Person Small Business Support