File indexing completed on 2024-04-14 14:19:53

0001 /*
0002     Copyright 2010 John Layt <john@layt.net>
0003 
0004     This library is free software; you can redistribute it and/or
0005     modify it under the terms of the GNU Library General Public
0006     License as published by the Free Software Foundation; either
0007     version 2 of the License, or (at your option) any later version.
0008 
0009     This library is distributed in the hope that it will be useful,
0010     but WITHOUT ANY WARRANTY; without even the implied warranty of
0011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012     Library General Public License for more details.
0013 
0014     You should have received a copy of the GNU Library General Public License
0015     along with this library; see the file COPYING.LIB.  If not, write to
0016     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017     Boston, MA 02110-1301, USA.
0018 */
0019 
0020 #ifndef KCALENDARERA_H
0021 #define KCALENDARERA_H
0022 
0023 #include <QString>
0024 #include <QDate>
0025 
0026 #include "klocale.h"
0027 
0028 class KCalendarSystemPrivate;
0029 
0030 /**
0031   * @internal
0032   * Class to hold details of a Calendar Era.  Internal for now, but may later be
0033   * made public if user configuration of Era formatting via System Settings is
0034   * required, in which case a d-ptr will be needed.  Details based on POSIX LC_TIME
0035   * format.
0036   *
0037   * @b license GNU-LGPL v.2 or later
0038   *
0039   * @see KCalendarSystem
0040   *
0041   * @author John Layt <john@layt.net>
0042 */
0043 class KCalendarEra
0044 {
0045 public:
0046     KDELIBS4SUPPORT_DEPRECATED explicit KCalendarEra();
0047     virtual ~KCalendarEra();
0048 
0049     bool isValid() const;
0050 
0051     int sequence() const;
0052     QDate startDate() const;
0053     QDate endDate() const;
0054     QString name(KLocale::DateTimeComponentFormat format = KLocale::DefaultComponentFormat) const;
0055     QString format() const;
0056     int direction() const;
0057     int offset() const;
0058 
0059     bool isInEra(const QDate &date) const;
0060     int yearInEra(int year) const;
0061     int year(int yearInEra) const;
0062 
0063 private:
0064     friend class KCalendarSystemPrivate;
0065 
0066     int m_sequence;
0067     QDate m_startDate;
0068     int m_startYear;
0069     QDate m_endDate;
0070     QString m_longName;
0071     QString m_shortName;
0072     QString m_format;
0073     int m_direction;
0074     int m_offset;
0075 };
0076 
0077 #endif // KCALENDARERA_H