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 AZTECXIHUITLCALENDAR_HPP 20 #define AZTECXIHUITLCALENDAR_HPP 21 22 #include "Calendar.hpp" 23 24 //! The Aztec Xihuitl was similar to the Maya Haab, a 365-day Solar calendar without intercalation. 25 //! The major difference is that days are counted 1...20, not 0...19. 26 //! Similar to the Egyptian calendar, after 18 months of 20 days there was a short "month" of 5 extra days (Nemontemi). 27 //! Some communities place this month of "worthless" days elsewhere in the sequence, this cannot be mapped here. 28 //! The implementation follows CC. 29 class AztecXihuitlCalendar : public Calendar 30 { 31 Q_OBJECT 32 33 public: 34 AztecXihuitlCalendar(double jd); 35 ~AztecXihuitlCalendar()36 virtual ~AztecXihuitlCalendar() Q_DECL_OVERRIDE {} 37 38 public slots: 39 virtual void retranslate() Q_DECL_OVERRIDE; 40 41 //! Set a calendar date from the Julian day number 42 virtual void setJD(double JD) Q_DECL_OVERRIDE; 43 44 //! set date from a vector of calendar date elements sorted from the largest to the smallest. 45 //! month[1..19]-day[1..20] 46 //! We face a problem as the year is not counted. We can only find the date before current JD which matches the parts. 47 virtual void setDate(QVector<int> parts) Q_DECL_OVERRIDE; 48 49 //! get a stringlist of calendar date elements sorted from the largest to the smallest. 50 //! monthName-day[1..20] 51 virtual QStringList getDateStrings() const Q_DECL_OVERRIDE; 52 53 //! get a formatted complete string for a date 54 virtual QString getFormattedDateString() const Q_DECL_OVERRIDE; 55 56 public: 57 //! find number in sequence from a xihuitl date of {month[1...19], day[1...20]} aztecXihuitlOrdinal(QVector<int> xihuitl)58 inline static int aztecXihuitlOrdinal(QVector<int> xihuitl) {return (xihuitl.at(0)-1)*20+xihuitl.at(1)-1;} 59 60 //! get 2-part vector of xihuitl date from RD 61 static QVector<int> aztecXihuitlFromFixed(int rd); 62 63 //! find RD number of a Xihuitl date on or before rd. 64 static int aztecXihuitlOnOrBefore(QVector<int> xihuitl, int rd); 65 66 //! get RD of a combined date on or before rd. They repeat every 18980 days. 67 static int aztecXihuitlTonalpohualliOnOrBefore(QVector<int>xihuitl, QVector<int>tonalpohualli, int rd); 68 69 //! Aztec date of fall of Tenochtitlan 70 static const int aztecCorrelation; 71 static const int aztecXihuitlCorrelation; 72 73 74 private: 75 static QMap<int, QString> monthNames; 76 }; 77 78 #endif 79