xref: /PHP-7.2/ext/calendar/dow.c (revision 60a69dae)
1 /* $selId: dow.c,v 2.0 1995/10/24 01:13:06 lees Exp $
2  * Copyright 1993-1995, Scott E. Lee, all rights reserved.
3  * Permission granted to use, copy, modify, distribute and sell so long as
4  * the above copyright and this permission statement are retained in all
5  * copies.  THERE IS NO WARRANTY - USE AT YOUR OWN RISK.
6  */
7 
8 /**************************************************************************
9  *
10  * These are the externally visible components of this file:
11  *
12  *     int
13  *     DayOfWeek(
14  *         long int sdn);
15  *
16  * Convert a SDN to a day-of-week number (0 to 6).  Where 0 stands for
17  * Sunday, 1 for Monday, etc. and 6 stands for Saturday.
18  *
19  *     char *DayNameShort[7];
20  *
21  * Convert a day-of-week number (0 to 6), as returned from DayOfWeek(), to
22  * the abbreviated (three character) name of the day.
23  *
24  *     char *DayNameLong[7];
25  *
26  * Convert a day-of-week number (0 to 6), as returned from DayOfWeek(), to
27  * the name of the day.
28  *
29  **************************************************************************/
30 
31 #include "sdncal.h"
32 
DayOfWeek(zend_long sdn)33 int DayOfWeek(
34 				 zend_long sdn)
35 {
36 	int dow;
37 
38 	dow = (sdn + 1) % 7;
39 	if (dow >= 0) {
40 		return (dow);
41 	} else {
42 		return (dow + 7);
43 	}
44 }
45 
46 char *DayNameShort[7] =
47 {
48 	"Sun",
49 	"Mon",
50 	"Tue",
51 	"Wed",
52 	"Thu",
53 	"Fri",
54 	"Sat"
55 };
56 
57 char *DayNameLong[7] =
58 {
59 	"Sunday",
60 	"Monday",
61 	"Tuesday",
62 	"Wednesday",
63 	"Thursday",
64 	"Friday",
65 	"Saturday"
66 };
67 
68 /*
69  * Local variables:
70  * tab-width: 4
71  * c-basic-offset: 4
72  * End:
73  * vim600: sw=4 ts=4 fdm=marker
74  * vim<600: sw=4 ts=4
75  */
76