< InterpolationDifferences.c | index | JulianDay.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.

IsLeapYear.c

/* see page 62 */

#ifdef ASTROALGO
   #include <assert.h>
   #include <stdio.h>
   #include "AstroAlgo.h"
   __declspec(dllexport) short __stdcall
#else
   short
#endif

ShIsLeapYear(short *pshResult, short shYear, short shCalendar)
                  /* shCalendar JULIAN for julian, GREGORIAN for gregorian */
   {
   short shReturnValue = (short) 0;

   if (pshResult != NULL)
      {
      *pshResult = (short) -1;
      }

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

   else if (shCalendar == (short) JULIAN)
      {
      if ((shYear % (short) 4) == 0)
         {
         *pshResult = (short) 1;
         }
      else
         {
         *pshResult = (short) 0;
         }
      }

   else if (shCalendar == (short) GREGORIAN)
      {
      if (   ((shYear % (short) 4) == 0)
          && (   ((shYear % (short) 100) != 0)
              || ((shYear % (short) 400) == 0)
             )
         )
         {
         *pshResult = (short) 1;
         }
      else
         {
         *pshResult = (short) 0;
         }
      }

   else
      {
      shReturnValue = (short) 3;
      }

   return shReturnValue;
   }

< InterpolationDifferences.c | index | JulianDay.c >


printer friendly view

   
Google
 
Web www.christophedavid.org