Solved

Is the CTime function y2k compatible?

Posted on 1998-12-29
10
408 Views
Last Modified: 2008-03-03
I couldn't find an answer in microsoft's search page to the question: Is the CTime function y2k compatible?
Thanks
0
Comment
Question by:gilbert_chang
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 1

Accepted Solution

by:
The_Brain earned 50 total points
Comment Utility
Yes it should be, the time is calculated by how many millisecond have elapsed since 1/1/1998 00:00:00.000
and this has a limit of long, which is about 19/1/2039  69y 19d and a couple of hours etc.

So yes it should be.  (why do you want to know?)
 (I could be mistaken for CDate,,, but I don't really think so.)
The time is, if I am mistaken in the above, is calculated how many milliseconds elapsed since midinght (0:00) which in effect has nothing to do with y2000 or any year for that matter.

Hope I soothed your pondering thoughts.

0
 

Author Comment

by:gilbert_chang
Comment Utility
I need to show my users the time in their local machine.
The question might be redefined as to whether win95/win98 is Y2K compatible?
Thanks.
0
 
LVL 1

Expert Comment

by:The_Brain
Comment Utility
Still doesn't matter the time is still calculated the same way, independent of 98.

The date will have a problem. (if 98 is not compatible, might not.)
0
 
LVL 11

Expert Comment

by:alexo
Comment Utility
0
 
LVL 10

Expert Comment

by:RONSLOW
Comment Utility
CTime is only for dates up to 2038.  Depending on one's definition of Y2K compliance, this may or may not be good enough.

COleDateTime is valid up to the year 9999 (ie it is OK).

To quote from MSDN...

One of the most pervasive issues existing with development tools occurs with the ANSI Ctime function and the MFC Ctime (www.microsoft.com/ithome/topics/year2k/product/ctime.htm).

By strict definition, these are "Year 2000 compliant," because they don't cause problems when the clock ticks over to January 1, 2000. However, they will have a date problem after January 18, 2038. Check your code for these function calls.


0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 10

Expert Comment

by:RONSLOW
Comment Utility
Have a look at

http://www.microsoft.com/technet/topics/year2k/whitepaper/ctime.htm

Here is the text of that page...


Ctime

The information below pertains to Ctime and the impact that it has on products ability to work into the 21st century. Ctime is a function of the C programming language that is used to calculate time. There is a good deal of attention being paid to this topic as organizations are looking to deal with the Year 2000 issue. The reason this issue becomes germane to the Year 2000 is because its use places a finite time limit on the application that is making use of it.

The ANSI time functions as well as the MFC CTime depend on an internal variable time_t to store time values. The variable time_t is a 32-bit long int that can hold values up to 2147483647 before it overflows. The calculated time is based on the time_t variable, which is used as an offset (in seconds) from January 1, 1970. The maximum number of seconds that can be stored in the time_t value is 2147483647-a little over 68 years. This means that Ctime can only be used to calculate times up to the year 2038 (1970 + 68 years).

offset from January 1, 1970
typedef long time_t; /* time value */
Integer Limits LONG MAX 2147483647
3600 sec/hr
86400 sec/day
31536000 sec/year
2147483647 / 31536000 = 68.09625973491 (ignoring leap years for this rough calculation)

Here is another independent calculation taken from another e-mail thread discussing Year 2000 issues:

The MFC documentation for CTime::CTime states that the valid range for the nYear parameter is 1970 to 2038 (actual range is midnight, January 1, 1970, to January 18, 19:14:07, 2038). These limits are based on the underlying time_t value that mktime creates from the struct tm. Most, if not all, ANSI C systems use 1970 as the reference date and overflow in 2038 (time_t is a long int that holds the number of seconds since the reference date).

There has been a considerable amount of inconsistent information about this topic over the past few months. For that reason, Microsoft chose to place a 35-year timeframe for our Year 2000 statement of compliance. In this way, we address concerns on this issue expressed to us by the greatest number of customers.


THE INFORMATION CONTAINED IN THIS DOCUMENT IS PROVIDED TO CUSTOMERS FOR THE SOLE PURPOSE OF ASSISTING THE PLANNING FOR THE TRANSITION TO THE YEAR 2000. THIS DOCUMENT CONTAINS THE INFORMATION CURRENTLY AVAILABLE CONCERNING THE BEHAVIOR OF MICROSOFT'S PRODUCTS IN THE NEXT CENTURY AND IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS, PUNITIVE OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY


0
 
LVL 1

Expert Comment

by:The_Brain
Comment Utility
I have already said all that.

long is 69 years and 19 days.  didn't you read the comments? :-)

anyway, that's fine, hope you got the better idea now.



0
 

Author Comment

by:gilbert_chang
Comment Utility
Thanks all.
0
 
LVL 1

Expert Comment

by:The_Brain
Comment Utility
oops it was suppose to say 1/1/1970 on my answer :)
ooooops sorry Rons.
0
 
LVL 10

Expert Comment

by:RONSLOW
Comment Utility
that's ok ... not sure why you're apologising to me .. but I'll accept it graciously :-)

0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now