From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f7344,5e0ef8d936a38c44 X-Google-Attributes: gidf7344,public X-Google-Thread: f86b3,5e0ef8d936a38c44 X-Google-Attributes: gidf86b3,public X-Google-Thread: fc89c,5e0ef8d936a38c44 X-Google-Attributes: gidfc89c,public X-Google-Thread: 1014db,5e0ef8d936a38c44 X-Google-Attributes: gid1014db,public X-Google-Thread: fc7fa,5e0ef8d936a38c44 X-Google-Attributes: gidfc7fa,public From: "John A. Kroll" Subject: Re: What do you look for in C/C++ source? tm_year? Date: 1997/09/03 Message-ID: <340D4287.2F3E9DA1@worldnet.att.net>#1/1 X-Deja-AN: 269682530 References: <340C34A2.FD0EE69F@bellsouth.net.no_spam> Organization: AT&T WorldNet Services Reply-To: krollj@worldnet.att.net Newsgroups: comp.software.year-2000,comp.unix.programmer,comp.os.vms,comp.sys.vms,comp.lang.c David Means wrote: > If you're greping through 1000's of lines of ( C/C++ ) code for date related > bugs, what do you look for? My first assumption is to find tm_year. > > What other stuff do you look for? > > Thanks > > David Means > Then of course there is always leap year calculations. The simple function that is always seen is something along the following: int check_leap_year( int test_year ) { return ( ( ( (test_year % 4) == 0 ) && ( (test_year % 100) != 0 ) ) || ( (test_year % 400) == 0 ) ); } Note that this function fails to work when called as: check_leap_year( my_tm_struct.tm_year ) Also you probably want to write a simple test program to check your OS's C library functions. Several OS's until very recently still shipped with non-compliant date related library functions. So in answer to your question, while grep is a good place to start, you will still need to take a hard look at the code. John Kroll