Solved

y2k conformance in C

Posted on 1998-12-23
10
285 Views
Last Modified: 2010-04-15
How do I ensure that my programs are Y2K compliant while writing programs in C?
0
Comment
Question by:duraisk
  • 5
  • 3
  • 2
10 Comments
 
LVL 11

Accepted Solution

by:
alexo earned 20 total points
ID: 1255378
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
 
LVL 1

Author Comment

by:duraisk
ID: 1255379
Ok that is fine for my module.but how if a parameter is passed by ref. to that ?
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1255380
You could also, of course, set the date on your computer to Jan 2000 and see if the program still works fine :-)
0
 
LVL 11

Expert Comment

by:alexo
ID: 1255381
>> but how if a parameter is passed by ref. to that ?
I don't follow, please elaborate.
0
 
LVL 11

Expert Comment

by:alexo
ID: 1255382
Hello?
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 6

Expert Comment

by:thresher_shark
ID: 1255383
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
 
LVL 11

Expert Comment

by:alexo
ID: 1255384
T_S, you're so encouraging...
0
 
LVL 1

Author Comment

by:duraisk
ID: 1255385
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
 
LVL 1

Author Comment

by:duraisk
ID: 1255386
Hi T_S
u r partly right and partly wrong
OK
0
 
LVL 11

Expert Comment

by:alexo
ID: 1255387
>> 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Retrun object in plist format 5 50
Beginner Probleme with my IDE Code::Blocks C++ 5 228
Problem with MFCApp 78 317
Problem to ASCII 1 148
Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

757 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

17 Experts available now in Live!

Get 1:1 Help Now