Added compatibility for PAF 4.
[gedcom-parse.git] / gedcom / calendar / dow.c
1 /* This file is taken from http://www.genealogy.org/~scottlee/
2    Only this initial comment has been added.  The next comment
3    gives the original copyright notice.
4 */
5
6
7 /* $selId: dow.c,v 2.0 1995/10/24 01:13:06 lees Exp $
8  * Copyright 1993-1995, Scott E. Lee, all rights reserved.
9  * Permission granted to use, copy, modify, distribute and sell so long as
10  * the above copyright and this permission statement are retained in all
11  * copies.  THERE IS NO WARRANTY - USE AT YOUR OWN RISK.
12  */
13
14 /**************************************************************************
15  *
16  * These are the externally visible components of this file:
17  *
18  *     int
19  *     DayOfWeek(
20  *         long int sdn);
21  *
22  * Convert a SDN to a day-of-week number (0 to 6).  Where 0 stands for
23  * Sunday, 1 for Monday, etc. and 6 stands for Saturday.
24  *
25  *     char *DayNameShort[7];
26  *
27  * Convert a day-of-week number (0 to 6), as returned from DayOfWeek(), to
28  * the abbreviated (three character) name of the day.
29  *
30  *     char *DayNameLong[7];
31  *
32  * Convert a day-of-week number (0 to 6), as returned from DayOfWeek(), to
33  * the name of the day.
34  *
35  **************************************************************************/
36
37 #include "sdncal.h"
38
39 int
40 DayOfWeek(
41     long int sdn)
42 {
43     int dow;
44
45     dow = (sdn + 1) % 7;
46     if (dow >= 0) {
47         return(dow);
48     } else {
49         return(dow + 7);
50     }
51 }
52
53 char *DayNameShort[7] = {
54     "Sun",
55     "Mon",
56     "Tue",
57     "Wed",
58     "Thu",
59     "Fri",
60     "Sat"
61 };
62
63 char *DayNameLong[7] = {
64     "Sunday",
65     "Monday",
66     "Tuesday",
67     "Wednesday",
68     "Thursday",
69     "Friday",
70     "Saturday"
71 };