commit | author | age
|
66d68b
|
1 |
/* |
U |
2 |
Zeitrechnung - a class library to determine calendar events |
|
3 |
Copyright (c) 1984-2023 Ulrich Hilger, http://uhilger.de |
|
4 |
|
|
5 |
This program is free software: you can redistribute it and/or modify |
|
6 |
it under the terms of the GNU Affero General Public License as published by |
|
7 |
the Free Software Foundation, either version 3 of the License, or |
|
8 |
(at your option) any later version. |
|
9 |
|
|
10 |
This program is distributed in the hope that it will be useful, |
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
GNU Affero General Public License for more details. |
|
14 |
|
|
15 |
You should have received a copy of the GNU Affero General Public License |
|
16 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
17 |
*/ |
|
18 |
package de.uhilger.zeitrechnung.ereignis; |
|
19 |
|
|
20 |
import de.uhilger.zeitrechnung.Datum; |
|
21 |
import de.uhilger.zeitrechnung.Definition; |
|
22 |
import de.uhilger.zeitrechnung.kalender.HebraeischerKalender; |
|
23 |
import de.uhilger.zeitrechnung.kalender.ISOKalender; |
|
24 |
import java.util.ArrayList; |
|
25 |
import java.util.List; |
|
26 |
|
|
27 |
/** |
|
28 |
* Ein Ereignis, das durch ein Datum im hebraeischen Kalender |
|
29 |
* definiert ist. |
|
30 |
* |
|
31 |
* <p> |
|
32 |
* Die Ereignis-Definition lautet:<br> |
|
33 |
* HebraeischesEreignis.getDefinition.setp1(Monat des hebraeischen Kalenders);<br> |
|
34 |
* HebraeischesEreignis.getDefinition.setp2(Tag im Monat des hebraeischen Kalenders);<br> |
|
35 |
* wobei Monat einer Ganzzahl aus |
|
36 |
* [HebraeischerKalender.NISAN .. HebraeischerKalender.ADAR] |
|
37 |
* entspricht. |
|
38 |
* </p> |
|
39 |
* |
|
40 |
* @author Ulrich Hilger |
|
41 |
*/ |
|
42 |
public class HebraeischesEreignis extends EreignisBasis { |
|
43 |
|
|
44 |
@Override |
|
45 |
public int getTyp() { |
|
46 |
return EreignisBasis.TYP_HEBRAEISCH; |
|
47 |
} |
|
48 |
|
|
49 |
@Override |
|
50 |
public List<Datum> getZeitpunkte(long isoJahr) { |
|
51 |
ISOKalender w = new ISOKalender(); |
|
52 |
long start = w.zuTagen(isoJahr, Definition.JANUAR, 1); |
|
53 |
long end = w.zuTagen(isoJahr, Definition.DEZEMBER, 31); |
|
54 |
|
|
55 |
HebraeischerKalender j = new HebraeischerKalender(); |
|
56 |
Datum hStart = j.vonTagen(start); |
|
57 |
long hStartJahr = hStart.getJahr(); |
|
58 |
Datum hEnd = j.vonTagen(end); |
|
59 |
long hEndJahr = hEnd.getJahr(); |
|
60 |
long anzahlJahre = (hEndJahr - hStartJahr) + (long) 1; |
|
61 |
|
|
62 |
Definition def = getDefinition(); |
|
63 |
List daten = new ArrayList(); |
|
64 |
for (long y = 0; y < anzahlJahre; y++) { |
|
65 |
long fixedDate = j.zuTagen(hStartJahr + y, (int) def.getp1(), (int) def.getp2()); |
|
66 |
if (fixedDate >= start && fixedDate <= end) { |
|
67 |
Datum d = w.vonTagen(fixedDate); |
|
68 |
daten.add(d); |
|
69 |
} |
|
70 |
} |
|
71 |
return daten; |
|
72 |
} |
|
73 |
|
|
74 |
} |