dateplus.c
#pragma ident "@(#)dateplus.c $Header"
/* static char SccsId[] = "@(#)dateplus.c 2.0 05/30/03"; */
/*--------------------------------------------------------------------*/
/* dateplus.c */
/* ---------------------------------------------------------------- */
/* Program documentation and notes located in the */
/* show_documentation() function. */
/*--------------------------------------------------------------------*/
/*====================================================================*/
/* D E C L A R A T I O N S */
/*====================================================================*/
#include <stdio.h>
#include <stdlib.h> /* abs, atoi, exit */
#include <string.h> /* strlen, strncpy */
#include <ctype.h> /* isdigit */
#include <time.h> /* time routines */
#define H24SSS 86400 /* Number of seconds in a day */
#define FALSE 0
#define TRUE 1
#define STRNCPY(to, from, n) {strncpy(to, from, n);to[n] = 0x0;}
/*====================================================================*/
/* P R O T O T Y P E S */
/*====================================================================*/
long calc_basedate(int yyyy, int mm, int dd);
int leap_year(int yyyy);
void show_documentation(char *progname);
int this_years_days(int yyyy);
void usage(char *progname);
void validate_mm_dd(int mm, int dd);
/*====================================================================*/
/* G L O B A L V A R I A B L E S */
/*====================================================================*/
int yyyy;
int ddddd;
const char *months[] = /* Month names */
{
"January", "February", "March" ,
"April" , "May" , "June" ,
"July" , "August" , "September",
"October", "November", "December"
};
/*====================================================================*/
/* M A I N */
/*====================================================================*/
main(int argc, char *argv[])
{
int julian_days[] = {0,31,59,90,120,151,181,212,243,273,304,334,365};
int julian_leap[] = {0,31,60,91,121,152,182,213,244,274,305,335,366};
int *accum_days = &julian_days[0]; /* julian_days address to ptr */
/*--------------------------------------------------------------------*/
/* Variables for weekday calculations */
/* */
const char *weekdays[] = {"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
int weekday_wanted = FALSE; /* Initially false.
|