-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDayOfWeek.c
More file actions
98 lines (74 loc) · 2.21 KB
/
DayOfWeek.c
File metadata and controls
98 lines (74 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/**************************************************************************
AstronomicalAlgorithms
A portable ANSI C implementation of some of the algorithms published in
Astronomical Algorithms
by Jean Meeus
2nd edition (December 1998)
Willmann-Bell
ISBN: 0943396638
by Christophe DAVID (christophe.david@christophedavid.org)
You may use parts of this source code as long as
- you mention clearly that its latest version can be obtained
free of charge at
http://www.christophedavid.org/
AND
- you send me a free copy of whatever you make using this code.
Comments and suggestions welcome.
**************************************************************************/
/*!
@file
@brief calculates the day of the week for a given date
@author Christophe DAVID \n
christophe.david@christophedavid.org \n
http://www.christophedavid.org
@since 01/07/1999
@version 1.0
@date 05/04/2001
@bug no known bug
@param double * DayOfWeek
@param double year
@param double month
@param double day
@return
- 0 : completed successfully
- 1 : error in parameter 1
- 2 : error in parameter 2
- 3 : error in parameter 3
- 4 : error in parameter 4
@if logger
@image html http://www.mot.be/cgi-bin/logger.cgi?DayOfWeek.c
@endif
*/
/* see page 65 */
/* DOW = 0 for Sunday, ..., 6 for Saturday */
#ifdef ASTROALGO
#include <math.h>
#include <stdio.h>
#include "AstronomicalAlgorithms.h"
#if _WIN32
__declspec(dllexport) short __stdcall
#endif
#else
short
#endif
int
ShDayOfWeek(short *pshDOW, double doY, double doM, double doD)
{
short shReturnValue = (short) 0;
if (pshDOW == NULL)
{
shReturnValue = (short) 1;
}
else
{
double doJD = (double) 0;
*pshDOW = (short) -1;
shReturnValue = ShJulianDay(&doJD, doY, doM, doD, (short) GREGORIAN);
if (shReturnValue == 0)
{
doJD += (double) 1.5;
*pshDOW = (short) ((unsigned long) doJD % (unsigned long) 7);
}
}
return shReturnValue;
}