Solved

Is the CTime function y2k compatible?

Posted on 1998-12-29
10
417 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 1

Accepted Solution

by:
The_Brain earned 50 total points
ID: 1181200
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
ID: 1181201
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
ID: 1181202
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Expert Comment

by:alexo
ID: 1181203
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1181204
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
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1181205
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
ID: 1181206
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
ID: 1181207
Thanks all.
0
 
LVL 1

Expert Comment

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

Expert Comment

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

0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

623 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