Back to index

php5  5.3.10
dow.c
Go to the documentation of this file.
00001 
00002 /* $selId: dow.c,v 2.0 1995/10/24 01:13:06 lees Exp $
00003  * Copyright 1993-1995, Scott E. Lee, all rights reserved.
00004  * Permission granted to use, copy, modify, distribute and sell so long as
00005  * the above copyright and this permission statement are retained in all
00006  * copies.  THERE IS NO WARRANTY - USE AT YOUR OWN RISK.
00007  */
00008 
00009 /**************************************************************************
00010  *
00011  * These are the externally visible components of this file:
00012  *
00013  *     int
00014  *     DayOfWeek(
00015  *         long int sdn);
00016  *
00017  * Convert a SDN to a day-of-week number (0 to 6).  Where 0 stands for
00018  * Sunday, 1 for Monday, etc. and 6 stands for Saturday.
00019  *
00020  *     char *DayNameShort[7];
00021  *
00022  * Convert a day-of-week number (0 to 6), as returned from DayOfWeek(), to
00023  * the abbreviated (three character) name of the day.
00024  *
00025  *     char *DayNameLong[7];
00026  *
00027  * Convert a day-of-week number (0 to 6), as returned from DayOfWeek(), to
00028  * the name of the day.
00029  *
00030  **************************************************************************/
00031 
00032 #include "sdncal.h"
00033 
00034 int DayOfWeek(
00035                              long int sdn)
00036 {
00037        int dow;
00038 
00039        dow = (sdn + 1) % 7;
00040        if (dow >= 0) {
00041               return (dow);
00042        } else {
00043               return (dow + 7);
00044        }
00045 }
00046 
00047 char *DayNameShort[7] =
00048 {
00049        "Sun",
00050        "Mon",
00051        "Tue",
00052        "Wed",
00053        "Thu",
00054        "Fri",
00055        "Sat"
00056 };
00057 
00058 char *DayNameLong[7] =
00059 {
00060        "Sunday",
00061        "Monday",
00062        "Tuesday",
00063        "Wednesday",
00064        "Thursday",
00065        "Friday",
00066        "Saturday"
00067 };
00068 
00069 /*
00070  * Local variables:
00071  * tab-width: 4
00072  * c-basic-offset: 4
00073  * End:
00074  * vim600: sw=4 ts=4 fdm=marker
00075  * vim<600: sw=4 ts=4
00076  */