Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!ames!haven!mimsy!tove.umd.edu!cml From: cml@tove.umd.edu (Christopher Lott) Newsgroups: comp.lang.c Subject: Re: Date-Routines for C/UNIX ? HELP Message-ID: <19559@mimsy.UUCP> Date: 13 Sep 89 13:32:21 GMT References: <298@nixsin.UUCP> <207600039@s.cs.uiuc.edu> Sender: nobody@mimsy.UUCP Reply-To: cml@tove.umd.edu.UUCP (Christopher Lott) Organization: The University of Maryland Dept of Computer Science Lines: 49 In article <207600039@s.cs.uiuc.edu> mccaugh@s.cs.uiuc.edu writes: > > I tried mailing to Mathias, but no luck...anyway, here (at least) is the > C code for day-of-week given the date as MMDDYYYY: >...... I was sent this function some time ago. The author's name appears below. Seems to work very well, and is nice and short. I have not tested it extensively. If someone can tell me more about the below-referenced "Zeller" function, I'd appreciate it. >From pats@cup.portal.com Thu Jun 29 10:27:56 1989 From: pats@cup.portal.com (Pat T Shea) Newsgroups: comp.sys.ibm.pc Subject: Re: calendar code Date: 29 Jun 89 00:19:58 GMT Organization: The Portal System (TM) 'think this is what ur looking for. . . . /pats. /*********************************************************************** * * int dmy2dow( int iDay, int iMon, int iYear ) - This is my * implementation of the Zeller function. It takes day/ * month/year and returns the day of the week as an int * with Sunday being 0.....etc. * /pats @Psi! * 11/05/85 ******/ int dmy2dow( int day, int mon, int year ) { int adj_mo, adj_yr, cent, cent_yrs; adj_mo = ( mon > 2 ) ? mon - 2 : mon + 10; adj_yr = ( mon > 2 ) ? year : year - 1; cent = adj_yr / 100; cent_yrs = adj_yr % 100; return((((( 13 * adj_mo - 1 ) / 5 ) + day + cent_yrs + ( cent_yrs / 4 ) + ( cent / 4 ) - 2 * cent + 77 ) % 7 )); } Hope this is useful to someone. chris... cml@tove.umd.edu Computer Science Dept, U. Maryland at College Park 4122 A.V.W. 301-454-8711