More on the Y2.038K Bug

Dr. GUI Online
September 30, 1998

Haven't you heard enough about these problems? Well, Dr. GUI has, too.

Despite the good doctor's desire to put the year 2000 behind him (wouldn't that be a trick in 1998?), astute readers noticed a couple of unresolved issues in my last column ("Dr. GUI on the Year 2038 Bug").

Chris Hubbard pointed out that there's still a problem with one COleDateTime method: the static method COleDateTime::GetCurrentTime. The current implementation calls the C run-time function time, which returns a time_t. This limitation isn't currently documented-it presumably took Chris's digging through the Microsoft Foundation Classes (MFC) source code to find it. (As Dr. GUI says, "Use the source, Luke!") Good job. Don't use this function if you need to be year 2038 compliant. Note also that COleDateTime has a constructor and assignment operator that take a time_t-don't use those either.

J. S. Jensen writes about the dates I quoted, reminding me that time_t is in seconds since midnight, January 1, 1970, coordinated universal time (UTC) or Greenwich mean time (GMT)-not local time (Pacific time here in Redmond). So the latest time is actually "Tue Jan 19 03:14:07 2038," according to the run-time library in Visual C++ version 6.0. He further points out that the time would roll over to "Fri Dec 13 20:45:52 1901," but that's kinda beside the point: the C Run-Time Libraries documentation (see the Visual C++ Programmer's Guide in the MSDN Library Online) pretty strongly implies that negative values in time_t variables (and therefore times before Jan 1, 1970) aren't allowed. (See documentation on mktime, which regards earlier times as errors and sets the time_t variable to -1.) A test program Dr. GUI wrote, which used gmtime to convert the time_t, general protection faulted (GPF) if the parameter to gmtime was negative.

But the best news comes from Bret Grinslade, who points out that under the 64-bit version of Windows NT, time_t will be defined as a 64-bit integer. That's plenty big-it'll work for millions of years. (No, Dr. GUI isn't going to calculate exactly how many.) So if you port your code to Windows NT 64 before you run into trouble, you'll be fine.

Mobile Channel Update

One of the cool features of the Palm-size PC is Mobile Channels, where your P/PC synchronizes to a specially formatted Internet Explorer 4.x channel.

By the way, Chris De Herrera's Windows CE Web site has a Mobile Channels list that's more complete than the one Microsoft publishes. There are only a few of these to which Dr. GUI subscribes-and he's not telling which ones, except to say that he's not subscribing to the Cardiology Channel because his specialty isn't cardiology (not because he doesn't have a heart).

Anyway, Chris's list of channels, from serious to silly to sublime, is at Besides MSNBC, Pen Computing, and the Cardiology Channel, some of the channels include:


2001 Microsoft Corporation. All rights reserved. Terms of use.

Copied to this site on March 12, 2001. As per the policy of this site.

Copied without permission.