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 ISOCALENDAR_HPP
20 #define ISOCALENDAR_HPP
21 
22 #include "GregorianCalendar.hpp"
23 
24 //! The ISO calendar counts weeks [1...53] in Gregorian years. Some dates in the border weeks 1 and 53 may lie outside of the respective year. Week 1 contains the first Thursday.
25 
26 class ISOCalendar : public GregorianCalendar
27 {
28 	Q_OBJECT
29 
30 public:
31 	ISOCalendar(double jd);
32 
~ISOCalendar()33 	virtual ~ISOCalendar() Q_DECL_OVERRIDE {}
34 
35 public slots:
36 	//! Set a calendar date from the Julian day number
37 	virtual void setJD(double JD) Q_DECL_OVERRIDE;
38 
39 	//! set date from a vector of calendar date elements sorted from the largest to the smallest.
40 	//! Year-Week[1...53]-Day[1...7]
41 	virtual void setDate(QVector<int> parts) Q_DECL_OVERRIDE;
42 
43 //	//! get a stringlist of calendar date elements sorted from the largest to the smallest.
44 //	//! The order depends on the actual calendar
45 //	virtual QStringList getDateStrings() Q_DECL_OVERRIDE;
46 
47 	//! get a formatted complete string for a date
48 	virtual QString getFormattedDateString() const Q_DECL_OVERRIDE;
49 
50 public:
51 	static QVector<int> isoFromFixed(int rd);
52 	static int fixedFromISO(QVector<int> iso);
53 };
54 
55 #endif
56