IT-DISCUSS Archives

March 2001

IT-DISCUSS@LIST.UVM.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Mike Austin <[log in to unmask]>
Reply To:
Departmental Technology Coordinators <[log in to unmask]>
Date:
Fri, 30 Mar 2001 10:35:21 -0500
Content-Type:
TEXT/PLAIN
Parts/Attachments:
TEXT/PLAIN (95 lines)
And we thought all our date problems were over with Y2K.  :)

mga.


---------- Forwarded message ----------
Date: Thu, 29 Mar 2001 17:00:22 EST
Subject: Re: The April Fools 2001 bug in Windows

On Wed, 28 Mar 2001 09:14:06 -0500, "Richard M. Smith"
<[log in to unmask]> wrote:

>Applications built with certain versions of Visual C++ could
>start giving the wrong time of day starting on Sunday.  The problem
>will last for a week.

>Here is a Microsoft FAQ about the bug:
>
>   http://msdn.microsoft.com/visualc/headlines/2001.asp

Additional resource with quoted text re-ordered from
http://support.microsoft.com/support/kb/articles/Q214/6/61.ASP

Microsoft has confirmed this to be a bug in the Microsoft products
Microsoft Visual C++, 32-bit Editions, versions 4.1, 4.2, 5.0, 6.0
This bug was corrected in Visual Studio 6.0 Service Pack 3.

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

>Unfortunately not all applications can be corrected with a new release of
>MSVCRT.DLL.  Any applications which statically links with the Visual C++
>runtime will have to be fixed by the application vendor.  Users will
>have to download the new releases of these kinds of applications.

The following sample program reproduces the problem:
// ----------------- start of sample program -------------------------
// ----------------- Code Courtesy MSFT Q214661 -------------------
// 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 ---------------------------

ATOM RSS1 RSS2