-
Notifications
You must be signed in to change notification settings - Fork 0
/
choliday.cpp
114 lines (101 loc) · 3.19 KB
/
choliday.cpp
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/****************************************************************************************
*
* This file is part of the MEGA-Series Project.
* Copyright (C) 2014 Joerg Pauly
* Created 04.04.2014 by joerg
* All Rights reserved
*
* Alle Programme der MEGA-Serie sind Freie Software: Sie können sie unter den Bedingungen
* der GNU Lesser General Public License, wie von der Free Software Foundation,
* Version 3 der Lizenz oder (nach Ihrer Option) jeder späteren
* veröffentlichten Version, weiterverbreiten und/oder modifizieren.
*
* Dieses Programm wird in der Hoffnung, dass es nützlich sein wird, aber
* OHNE JEDE GEWÄHRLEISTUNG, bereitgestellt; sogar ohne die implizite
* Gewährleistung der MARKTFÄHIGKEIT oder EIGNUNG FÜR EINEN BESTIMMTEN ZWECK.
* Siehe die GNU Lesser General Public License für weitere Details.
*
* Sie sollten eine Kopie der GNU Lesser General Public License zusammen mit diesem
* Programm erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
*
*****************************************************************************************/
/* Liste aller Feiertage
1,1,jahr, "Neujahr"
15,8,jahr, "Mariä Himmelfahrt"
1,11,jahr, "Allerheiligen"
8,12,jahr, "Maria Empfängnis"
24,12,jahr, "Heilig Abend"
25,12,jahr, "1.Weihnachtsfeiertag"
26,12,jahr, "2.Weihnachtsfeiertag"
// von Ostern abhängige Feiertage
Ostern-48 "Rosenmontag"
Ostern-7, "Palmsonntag"
Ostern-2, "Karfreitag"
Ostern-1, "Karsamstag"
Ostern, "Ostersonntag"
Ostern+1, "Ostermontag"
Ostern+39, "Christi Himmelfahrt"
Ostern+49, "Pfingstsonntag"
Ostern+50, "Pfingstmontag"
Ostern+60, "Fronleichnam"
*/
#include "choliday.h"
CHoliday::CHoliday(int pJahr)
{
makeOsterSonntag(pJahr);
makeHolidayList();
}
CHoliday::~CHoliday()
{
delete m_holidayList;
}
bool CHoliday::checkForHoliday(QDate pDate)
{
for(int i = 0; i < m_holidayList->count(); i++)
{
if(m_holidayList->at(i) == pDate)
{
return true;
}
}
if(pDate.dayOfWeek() > 5)
{
return true;
}
return false;
}
// Feiertagsliste aus Datenbank laden.
void CHoliday::makeHolidayList()
{
m_holidayList = new QList<QDate>();
CHolidayList *lLst = new CHolidayList();
QDate *lDate;
for(int i = 0; i < lLst->count(); i++)
{
if(!lLst->at(i).Movable())
{
lDate = new QDate(m_osterSonntag.year(), lLst->at(i).Month(), lLst->at(i).Day());
}
else
{
*lDate = m_osterSonntag.addDays(lLst->at(i).Day());
}
m_holidayList->append(*lDate);
}
}
void CHoliday::makeOsterSonntag(int pJahr)
{
int a = pJahr % 19;
int b = pJahr / 100;
int c = pJahr % 100;
int e = b % 4;
int f = (b + 8) / 25;
int g = (b - f + 1) / 3;
int h = (19 * a + b - (b/4) - g + 15) % 30;
int k = c % 4;
int l = (32 + 2 * e + 2 * (c / 4) - h - k) % 7;
int m = (a + 11 * h + 22 * l) / 451;
int nMonth = (h + l - 7 * m + 114) / 31;
int nDay = (h + l - 7 * m + 114) % 31 + 1;
m_osterSonntag.setDate(pJahr,nMonth,nDay);
}