• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • Contact Us
 

KDECore

kcalendarera.cpp

Go to the documentation of this file.
00001 /*
00002     Copyright 2010 John Layt <john@layt.net>
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to
00016     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017     Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include "kcalendarera_p.h"
00021 #include "kcalendarsystem.h"
00022 #include "kcalendarsystemprivate_p.h"
00023 
00024 #include "kdebug.h"
00025 
00026 #include <QtCore/QDate>
00027 
00028 KCalendarEra::KCalendarEra()
00029 {
00030 }
00031 
00032 KCalendarEra::~KCalendarEra()
00033 {
00034 }
00035 
00036 bool KCalendarEra::isValid() const
00037 {
00038     return m_startDate.isValid() &&
00039            m_startDate.isValid() &&
00040            !m_longName.isEmpty() &&
00041            !m_shortName.isEmpty() &&
00042            !m_format.isEmpty();
00043 }
00044 
00045 QDate KCalendarEra::startDate() const
00046 {
00047     return m_startDate;
00048 }
00049 
00050 QDate KCalendarEra::endDate() const
00051 {
00052     return m_endDate;
00053 }
00054 
00055 QString KCalendarEra::name(KLocale::DateTimeComponentFormat format) const
00056 {
00057     if (format == KLocale::LongName) {
00058         return m_longName;
00059     } else {
00060         return m_shortName;
00061     }
00062 }
00063 
00064 QString KCalendarEra::format() const
00065 {
00066     return m_format;
00067 }
00068 
00069 int KCalendarEra::direction() const
00070 {
00071     return m_direction;
00072 }
00073 
00074 bool KCalendarEra::isInEra( const QDate &date ) const
00075 {
00076     if ( m_endDate < m_startDate ) {
00077         return ( date >= m_endDate && date <= m_startDate );
00078     } else {
00079         return ( date >= m_startDate && date <= m_endDate );
00080     }
00081 }
00082 
00083 int KCalendarEra::yearInEra( int year ) const
00084 {
00085     return ( ( year - m_startYear ) * m_direction ) + m_offset;
00086 }
00087 
00088 int KCalendarEra::year( int yearInEra ) const
00089 {
00090     return ( ( yearInEra - m_offset ) / m_direction ) + m_startYear;
00091 }

KDECore

Skip menu "KDECore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal