/* librock_CHISEL _summary Compute day of week from a SDN (serial-day number) */ /**************************************************************/ #ifdef librock_NOTLIBROCK /* ABOUT THIS FILE: GUIDE TO QUICK REUSE WITHOUT REWORK This file uses many preprocessor conditional blocks and features to publish http://www.mibsoftware.com/librock/ You can disable those features with little or no editing, and reuse this file: 1. At compile time, enable this conditional block by defining the preprocessor symbol librock_NOTLIBROCK, either with a compiler command line parameter, or as a #define in a source file which then #includes this source file. 2. Define any preprocessor symbols in this block (if any) appropriately for your machine and compilation environment. 3. Copy and use the declarations from this block in your source files as appropriate. This file is originally from the librock library, which is Free (libre), free (no cost), rock-stable API, and works on gcc/MSVC/Windows/Linux/BSD/more. Get originals, updates, license certificates, more, at http://www.mibsoftware.com/librock/ (Change log appears at end of this file.) */ #define librock_ISOLATED #define librock_PTR #define librock_CONST const #define librock_assert(a) #endif /* ifdef librock_NOTLIBROCK */ /**************************************************************/ #ifndef librock_ISOLATED /**************************************************************/ #define librock_IMPLEMENT_dow #include /**************************************************************/ #endif #ifdef librock_IMPL_LIDESC #ifndef librock_NOIMPL_LIDESC_dow /**************************************************************/ /* License awareness system. See http://www.mibsoftware.com/librock */ #include /* librock_LIDESC_HC=553e181388455f0eef17ccd9e2a51c1f3ae8daf0 */ char *librock_LIDESC_dow[] = { "\n" __FILE__ librock_LIDESC_sdncal "\n", 0 }; /**************************************************************/ #endif #endif #ifdef librock_MANUAL_dow librock_CHISEL subject /hard/time/ /* librock_dow - Day of week determination (Scott E. Lee's sdncal library) */ /**/ #include int librock_DayOfWeek( long int sdn); /* Convert a SDN to a day-of-week number (0 to 6). Where 0 stands for * Sunday, 1 for Monday, etc. and 6 stands for Saturday. */ char *librock_DayNameShort[7]; /* * Convert a day-of-week number (0 to 6), as returned from DayOfWeek(), to * the abbreviated (three character) name of the day. */ char *librock_DayNameLong[7]; /* * Convert a day-of-week number (0 to 6), as returned from DayOfWeek(), to * the name of the day. */ /* */ /* Obtain sdn, the serial day number, from the other calendar conversion routines. */ /* //No external calls */ /* Copyright 1993-1995, Scott E. Lee, all rights reserved. Licensed under BSD-ish license, NO WARRANTY. Copies must retain this block. License text in librock_LIDESC_HC=553e181388455f0eef17ccd9e2a51c1f3ae8daf0 */ #endif /* MANUAL */ /* $selId: dow.c,v 2.0 1995/10/24 01:13:06 lees Exp $ * Copyright 1993-1995, Scott E. Lee, all rights reserved. * Permission granted to use, copy, modify, distribute and sell so long as * the above copyright and this permission statement are retained in all * copies. THERE IS NO WARRANTY - USE AT YOUR OWN RISK. */ /************************************************************************** * * These are the externally visible components of this file: * * int * DayOfWeek( * long int sdn); * * Convert a SDN to a day-of-week number (0 to 6). Where 0 stands for * Sunday, 1 for Monday, etc. and 6 stands for Saturday. * * char *DayNameShort[7]; * * Convert a day-of-week number (0 to 6), as returned from DayOfWeek(), to * the abbreviated (three character) name of the day. * * char *DayNameLong[7]; * * Convert a day-of-week number (0 to 6), as returned from DayOfWeek(), to * the name of the day. * **************************************************************************/ #include "sdncal.h" int DayOfWeek( long int sdn) { int dow; dow = (sdn + 1) % 7; if (dow >= 0) { return(dow); } else { return(dow + 7); } } char *DayNameShort[7] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; char *DayNameLong[7] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; /* $Log: dow.c,v $ Revision 1.4 2002/04/19 14:45:09 forrest@mibsoftware.com rights=#1 Correct license tags. Revision 1.3 2002/02/05 21:08:54 forrest@mibsoftware.com rights=#1 Standardized log Revision 1.2 2002/01/30 16:07:38 forrest@mibsoftware.com rights=#1 Renamed some .h files Revision 1.1 2002/01/28 17:29:10 forrest@mibsoftware.com rights=#1 Initial rights#1 Copyright (c) Forrest J Cavalier III d-b-a Mib Software rights#1 License text in librock_LIDESC_HC=12440211096131f5976d36be0cddca4cd9152e45 librock_ACQUIRED: 2001-10-30 ftp://ftp.genealogy.org/pub/users/scottlee/sdncal20.zip http://genealogy.org/~scottlee/cal-overview.html License text in librock_LIDESC_HC=553e181388455f0eef17ccd9e2a51c1f3ae8daf0 */