head 1.3; access ; symbols ; locks oasisa:1.3; strict; comment @ * @; 1.3 date 2001.06.20.18.16.18; author oasisa; state Exp; branches ; next 1.2; 1.2 date 2001.06.19.13.23.52; author oasisa; state Exp; branches ; next 1.1; 1.1 date 2001.06.19.13.03.15; author oasisa; state Exp; branches ; next ; desc @Periodic Update w/ changes to utils plus new utils 6/19/2001 (klh) @ 1.3 log @Cleanup version; added day of week, let time() do calcs @ text @/* */ /* $Header: jday.c,v 1.2 2001/06/19 13:23:52 oasisa Exp $ */ /* Copyright 2001 MBARI */ /* Author: Kent Headley */ /* $Revision: 1.2 $ */ /* Summary: Compute day of year */ /* Input: 0 or more dates mm/dd/yyyy; Default is current day */ /* Output: Day of year */ /* Notes: Compile with -I /usr/include */ /* */ /* MBARI provides this documentation and code "as is", with no warranty, */ /* express or implied, of its quality or consistency. It is provided without*/ /* support and without obligation on the part of the Monterey Bay Aquarium */ /* Research Institute to assist in its use, correction, modification, or */ /* enhancement. This information should not be published or distributed to */ /* third parties without specific written permission from MBARI. */ /* */ /* $Log: jday.c,v $ * Revision 1.2 2001/06/19 13:23:52 13:23:52 oasisa (Oasis users) * Added header, logs, revision * */ #include #include #include main(argc,argv) int argc; char *argv[]; { unsigned IsLeapYear=0; int year,month,day; int i; char *wdays[]={"Sun","Mon","Tue","Wed","Thu","Fri","Sat"}; int mo_days[]={0,31,28,31,30,31,30,31,31,30,31,30,31}; enum Months{JAN=1,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC}; struct tm *tp,when; time_t wtime; if (argc<2){ time(&wtime); tp = localtime( &wtime ); }else for(i=1;itm_wday],tp->tm_mon+1,tp->tm_mday,tp->tm_year+1900,tp->tm_yday+1); printf("Usage: %s mm/dd/yyyy\n\n",argv[0]); return(0); } @ 1.2 log @Added header, logs, revision @ text @d2 1 a2 1 /* $Header$ */ d5 5 a9 1 /* $Revision$ */ d18 4 a21 2 /* $Log$ d26 3 a28 3 #include d35 2 a36 1 int i,j,jday; d39 21 a59 25 struct tm *today; time_t ltime; if (argc<2){ time(<ime); today = localtime( <ime ); printf("%d\n",today->tm_yday+1); return(0); } for(i=1;imo_days[month]) if(!(day==29 && month==FEB && IsLeapYear)){ printf("Invalid date"); return(0); } for(j=0,jday=0;jFEB)?1:0)); printf("%d\n",jday); d61 3 a63 1 } @ 1.1 log @Initial revision @ text @d2 1 d5 1 d14 4 @