home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************/
- /* (c) 1988 by James N. Seed, Atlanta, GA - all rights reserved. */
- /* */
- /* This program is provided for example purposes only. It, and/or */
- /* its executable equivalent, may not be sold or distributed in any */
- /* form for profit, without the prior written consent of the author. */
- /* */
- /************************************************************************/
- /* */
- /* The idea of this program is to test the C_dates conversion */
- /* functions, "gtoj" and "jtog", on EVERY date from January 1st, 0000 */
- /* to December 31st, 9999. ( used it myself ) */
- /* */
- /* C_dates Initial release - errors show up */
- /* C_dates Version 2 - no errors */
- /* */
- /* Note: All other C_dates functions have always been error free. */
- /************************************************************************/
-
- #define LINT_ARGS
-
- #include "stdlib.h"
- #include "stdio.h"
- #include "c_dates.h"
-
- static char maxday[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
-
- static char julerr[] = " - \areturned an invalid julian number.";
- static char strerr[] = " - \acould not be converted properly.";
- static char nxtdte[] = "\n - checks out.";
- static char currnt[] = "\r%02u/%02u/%04u";
- static char aok[] = "\r All dates checked out - AOK !";
-
- void _setargv() { }
- void _setenvp() { }
-
- void main()
-
- {
- register unsigned month, day;
-
- unsigned year, chkdte[3], errjul = 0, errstr = 0;
- unsigned long julian = 0;
-
- for ( printf( nxtdte ), year = 0; year < 10000; ++year )
- {
- for ( month = 1; month < 13; ++month )
- {
- if ( month == 2 )
- maxday[ month ] = year % 4 ||
- ( !( year % 100 ) && year % 400 )
- ? 28 : 29;
-
- for ( day = 1; day <= maxday[ month ]; ++day )
- {
- printf( currnt, month, day, year );
-
- if ( gtoj( month, day, year ) != ++julian )
- {
- ++errjul;
- printf( julerr ), printf( nxtdte );
- }
- else
- {
- jtog( julian, (char *)chkdte, 0 );
-
- if ( !( chkdte[0] == month &&
- chkdte[1] == day &&
- chkdte[2] == year ) )
- {
- ++errstr;
- printf( strerr ), printf( nxtdte );
- }
- }
- }
- }
- }
-
- if ( !errjul && !errstr ) printf( aok );
-
- exit( 0 );
- }