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 OLYMPICCALENDAR_HPP 20 #define OLYMPICCALENDAR_HPP 21 22 #include "JulianCalendar.hpp" 23 24 //! The Olympic calendar only provides the counted olympiad and year in the 4-year cycle. Else it behaves like the Julian calendar. 25 //! setDate can take either 2 or 4 elements. In the first case, month/day are taken from the current Julian calendar date. 26 class OlympicCalendar : public JulianCalendar 27 { 28 Q_OBJECT 29 30 public: 31 OlympicCalendar(double jd); 32 ~OlympicCalendar()33 virtual ~OlympicCalendar() Q_DECL_OVERRIDE {} 34 35 public slots: retranslate()36 virtual void retranslate() Q_DECL_OVERRIDE {} 37 38 //! Set a calendar date from the Julian day number 39 virtual void setJD(double JD) Q_DECL_OVERRIDE; 40 41 //! set date from a vector of calendar date elements sorted from the largest to the smallest. 42 //! The elements only change years. The calendar is else based on the Julian, so 43 //! unless given explicitly, months and days in the Julian calendar will not be changed. 44 //! parts={olympiad, year [, month, day]} 45 virtual void setDate(QVector<int> parts) Q_DECL_OVERRIDE; 46 47 //! get a stringlist of calendar date elements sorted from the largest to the smallest. 48 //! Olympiad, Year 49 virtual QStringList getDateStrings() const Q_DECL_OVERRIDE; 50 51 //! get a formatted complete string for a date ("nth of the monthname, Year X in the YY olympiad") 52 virtual QString getFormattedDateString() const Q_DECL_OVERRIDE; 53 54 public: 55 static int julianYearFromOlympiad(QVector<int>odate); 56 57 static QVector<int> olympiadFromJulianYear(int jYear); 58 59 constexpr static const int olympiadStart=-776; 60 }; 61 62 #endif 63