• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 296
  • Last Modified:

y2k conformance in C

How do I ensure that my programs are Y2K compliant while writing programs in C?
0
duraisk
Asked:
duraisk
  • 5
  • 3
  • 2
1 Solution
 
alexoCommented:
1. Store full year in dates (1998 and not just 98).
2. Correctly calculate leap years (divides by 4 but not by 100 unless divides by 400)
3. Familiarize yourself with the time_t, clock_t and struct tm data types and the functions that use them (TIME.H header).
4. Make sure all the external functions you use (C runtime, OS APIs, third party libraries) abide by the same rules.

BTW, there is a Y2K area specifically for these questions...
0
 
duraiskAuthor Commented:
Ok that is fine for my module.but how if a parameter is passed by ref. to that ?
0
 
thresher_sharkCommented:
You could also, of course, set the date on your computer to Jan 2000 and see if the program still works fine :-)
0
Technology Partners: 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!

 
alexoCommented:
>> but how if a parameter is passed by ref. to that ?
I don't follow, please elaborate.
0
 
alexoCommented:
Hello?
0
 
thresher_sharkCommented:
duraisk may be accessing EE from work in which case he won't be using it for awhile (probably).  Of course it could also be a post-a-question-get-an-answer-and-then-forget-about-it situation
0
 
alexoCommented:
T_S, you're so encouraging...
0
 
duraiskAuthor Commented:
sorry i was little bit busy with the work. so i could not reply
I am in a project which involves writing code in C/C++. we were told to ensure that our programs are y2k conformant.In C i cannot declare variables  as "date" asin other languages. and also if short date values from other modules are passed to my modules how do i ensure that it is made compliant?. While testing, the whole product as such, how do go about testing?

0
 
duraiskAuthor Commented:
Hi T_S
u r partly right and partly wrong
OK
0
 
alexoCommented:
>> In C i cannot declare variables  as "date" as in other languages.
Incorrect.  Although they're part of the standard C library and not the language per se, there are time/date types (I mentioned time_t, clock_t and struct tm in my answer).  As long as you use them you are OK.  If you do your own time/date handling ensure 4 digits for year values and proper leap year handling.

>> if short date values from other modules are passed to my modules how do i ensure that it is made compliant?
Technically you cannot handle all cases.  If an external module passes you a year value of '84' while both 1984 and 2084 are valid in that context, you cannot distinguish between them.

There are certain cases where you can wing it.  If the legal year range in your app starts from, say, 1970 and you only get two digits, add 1900 if the year is greater or equal to 70 and 2000 otherwise.

>> how do go about testing?
Feed your app dates in the 1999-2099 year range and see if it breaks or reports incorrect results.  Set your computer clock to various dates in the above range and repeat the test.
0

Featured Post

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.

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