Unix Review > Archives > 2004 > March 2004

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. 

				  

Sys Admin Spotlight

CMP DevNet Spotlight

Global Web Site Performance Improvement
Jeffrey Fulmer explains how to get a comprehensive picture of your site's performance and describes some tips for improving it.

In the News

CD-ROM

Sys Admin and The Perl Journal CD-ROM version 11.0

Version 11.0 delivers every issue of Sys Admin from 1992 through 2005 and every issue of The Perl Journal from 1996-2002 in one convenient CD-ROM!

Order now!




MarketPlace

"Six Sigma" Certification
Villanova Six Sigma Certification 100% Online Program - Free Info.

PMP Certification-Online
Nation's Leading Online PMP Course From Villanova-Find Out More Now.

BugSplat - Automatic Crash Analysis
Fast online exception analysis. Capture customer crash data online.

Microsoft SQL Server 2008 Express - FREE Edition
Build Rich Desktop and Web Applications and Deploy to Most Versions of SQL Server.

Wanna see your ad here?