< DateFromYearDay.c | index | DayOfYear.c >

Copyright (c) 1999-2012

Permission to use, copy, modify, and distribute this software and its documentation under the terms of the GNU eneral Public License is hereby granted. No representations are made about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.

See the GNU General Public License.

DayOfWeek.c

/* see page 65 */

/* DOW = 0 for Sunday, ..., 6 for Saturday */

#ifdef ASTROALGO
   #include <math.h>
   #include <stdio.h>
   #include "AstroAlgo.h"

   __declspec(dllexport) short __stdcall
#else
   short
#endif

ShDayOfWeek(short *pshDOW, double doY, double doM, double doD)
   {
   short  shReturnValue = (short)  0;

   if (pshDOW == NULL)
      {
      shReturnValue = (short) 1;
      }

   else
      {
      double doJD = (double) 0;

      *pshDOW = (short) -1;
      shReturnValue = ShJulianDay(&doJD, doY, doM, doD, (short) GREGORIAN);
      if (shReturnValue == 0)
         {
         doJD += (double) 1.5;
         *pshDOW = (short) ((unsigned long) doJD % (unsigned long) 7);
         }
      }

   return shReturnValue;
   }

< DateFromYearDay.c | index | DayOfYear.c >


printer friendly view

   
Google
 
Web www.christophedavid.org