Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 419
  • Last Modified:

Is the CTime function y2k compatible?

I couldn't find an answer in microsoft's search page to the question: Is the CTime function y2k compatible?
Thanks
0
gilbert_chang
Asked:
gilbert_chang
  • 4
  • 3
  • 2
  • +1
1 Solution
 
The_BrainCommented:
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
 
gilbert_changAuthor Commented:
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
 
The_BrainCommented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
RONSLOWCommented:
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
 
RONSLOWCommented:
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
 
The_BrainCommented:
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
 
gilbert_changAuthor Commented:
Thanks all.
0
 
The_BrainCommented:
oops it was suppose to say 1/1/1970 on my answer :)
ooooops sorry Rons.
0
 
RONSLOWCommented:
that's ok ... not sure why you're apologising to me .. but I'll accept it graciously :-)

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now