1 /*
2  * Copyright (C) 2020 Georg Zotti
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.
17  */
18 
19 #ifndef COPTICCALENDAR_HPP
20 #define COPTICCALENDAR_HPP
21 
22 #include "JulianCalendar.hpp"
23 
24 //! Based on the Egyptian calendar (esp. the month names!), but with leap years like the Julian. CC.UE chapter 4.
25 //! Epoch is the era of Diocletian (Era Martyrum)
26 
27 class CopticCalendar : public JulianCalendar
28 {
29 	Q_OBJECT
30 
31 public:
32 	CopticCalendar(double jd);
33 
~CopticCalendar()34 	virtual ~CopticCalendar() Q_DECL_OVERRIDE {}
35 
36 public slots:
37 	virtual void retranslate() Q_DECL_OVERRIDE;
38 
39 	//! Set a calendar date from the Julian day number
40 	virtual void setJD(double JD) Q_DECL_OVERRIDE;
41 
42 	//! set date from a vector of calendar date elements sorted from the largest to the smallest.
43 	//! Year-Month[1...13]-Day[1...30]
44 	virtual void setDate(QVector<int> parts) Q_DECL_OVERRIDE;
45 
46 	//! get a stringlist of calendar date elements sorted from the largest to the smallest.
47 	//! Year, Month, MonthName, Day, DayName
48 	virtual QStringList getDateStrings() const Q_DECL_OVERRIDE;
49 
50 	//! get a formatted complete string for a date
51 	virtual QString getFormattedDateString() const Q_DECL_OVERRIDE;
52 
53 public:
54 	//! find RD number for date in the Coptic calendar (may be used in other calendars!)
55 	static int fixedFromCoptic(QVector<int> coptic);
56 	//! find date in the Coptic calendar from RD number (may be used in other calendars!)
57 	static QVector<int> copticFromFixed(int rd);
58 
59 	//! returns true for leap years
60 	static bool isLeap(int year);
61 
62 	static const int copticEpoch; //! RD of 284-aug-29 (Jul).
63 
64 protected:
65 	static QMap<int, QString> monthNames;
66 	static QMap<int, QString> dayNames;
67 
68 	static QString weekday(double jd);
69 };
70 
71 #endif
72