| iMatix home page
| << | < | > | >>
SFL Logo SFL
Version 2.11

 

day_of_week

#include "sfldate.h"
int
day_of_week (long date)

Synopsis

Returns the day of the week where 0 is Sunday, 1 is Monday, ... 6 is Saturday. Uses Zeller's Congurence algorithm.

Source Code - (sfldate.c)

{
    int
        year  = GET_CCYEAR (date),
        month = GET_MONTH  (date),
        day   = GET_DAY    (date);

    if (month > 2)
        month -= 2;
    else
      {
        month += 10;
        year--;
      }
    day = ((13 * month - 1) / 5) + day + (year % 100) +
          ((year % 100) / 4) + ((year / 100) / 4) - 2 *
           (year / 100) + 77;

    return (day - 7 * (day / 7));
}

| << | < | > | >> iMatix Copyright © 1996-2000 iMatix Corporation