-rw-r--r-- | core/pim/datebook/holiday/christian/chrisholiday.cpp | 191 | ||||
-rw-r--r-- | core/pim/datebook/holiday/christian/chrisholiday.h | 66 | ||||
-rw-r--r-- | core/pim/datebook/holiday/christian/hlist.cpp | 36 | ||||
-rw-r--r-- | core/pim/datebook/holiday/christian/hlist.h | 32 |
4 files changed, 163 insertions, 162 deletions
diff --git a/core/pim/datebook/holiday/christian/chrisholiday.cpp b/core/pim/datebook/holiday/christian/chrisholiday.cpp index be16bd0..ef6516e 100644 --- a/core/pim/datebook/holiday/christian/chrisholiday.cpp +++ b/core/pim/datebook/holiday/christian/chrisholiday.cpp @@ -1,95 +1,96 @@ -#include "chrisholiday.h"
-
-#include <qobject.h>
-
-QString ChrisHoliday::description()
-{
- return QObject::tr("Christian holidays","holidays");
-}
-
-QStringList ChrisHoliday::entries(const QDate&aDate)
-{
- QStringList ret;
- ret+=_internallist.entries(aDate);
- calcit(aDate.year());
- tDayMap::Iterator it = _days.find(aDate);
- if (it!=_days.end()) {
- ret+=*it;
- }
-
- return ret;
-}
-
-QStringList ChrisHoliday::entries(unsigned year, unsigned month, unsigned day)
-{
- return entries(QDate(year,month,day));
-}
-
-void ChrisHoliday::calcit(int year)
-{
- if (year==_lastyear) return;
- _lastyear = year;
- _days.clear();
- calc_easter();
- calc_christmas();
-}
-
-void ChrisHoliday::calc_christmas()
-{
- QDate cday(_lastyear,12,24);
- int diff;
- if ( (diff=cday.dayOfWeek())!=7) {
- cday=cday.addDays(-diff);
- _days[cday].append(QObject::tr("4. Advent","holidays"));
- }
- _days[cday.addDays(-7)].append(QObject::tr("3. Advent","holidays"));
- _days[cday.addDays(-14)].append(QObject::tr("2. Advent","holidays"));
- _days[cday.addDays(-21)].append(QObject::tr("1. Advent","holidays"));
-}
-
-void ChrisHoliday::calc_easter()
-{
- unsigned long n = 0;
- unsigned long p = 0;
-
- if ( _lastyear > 1582 ) {
- unsigned long a = _lastyear%19;
- unsigned long b = _lastyear/100;
- unsigned long c = _lastyear%100;
- unsigned long d = b/4;
- unsigned long e = b%4;
- unsigned long f = (b+8)/25;
- unsigned long g = (b+f+1)/3;
- unsigned long h = (19*a+b-d-g+15)%30;
- unsigned long i = c/4;
- unsigned long j = c%4;
- unsigned long k = j%100;
- unsigned long l = (32+2*e+2*i-h-k)%7;
- unsigned long m = (a+11*h+22*l)/451;
- n = (h+l-7*m+114)/31;
- p = (h+l-7*m+114)%31;
- } else {
- unsigned long a = _lastyear%4;
- unsigned long b = _lastyear%7;
- unsigned long c = _lastyear%19;
- unsigned long d = (19*c+15)%30;
- unsigned long e = (2*a+4*b-d+34)%7;
- n = (d+e+114)/31;
- p = (d+e+114)%31;
- }
- p++;
- QDate d(_lastyear,n,p);
- _days[d].append(QObject::tr("Eastersunday","holidays"));
- _days[d.addDays(49)].append(QObject::tr("Whitsunday","holidays"));
- _days[d.addDays(50)].append(QObject::tr("Whitmonday","holidays"));
- _days[d.addDays(-46)].append(QObject::tr("Ash Wednesday","holidays"));
- _days[d.addDays(60)].append(QObject::tr("Corpus Christi","holidays"));
-}
-
-QMap<QDate,QStringList> ChrisHoliday::entries(const QDate&,const QDate&)
-{
- QMap<QDate,QStringList> ret;
- return ret;
-}
-
-EXPORT_HOLIDAY_PLUGIN(ChrisHoliday);
+#include "chrisholiday.h" + +#include <qobject.h> + +QString ChrisHoliday::description() +{ + return QObject::tr("Christian holidays","holidays"); +} + +QStringList ChrisHoliday::entries(const QDate&aDate) +{ + QStringList ret; + ret+=_internallist.entries(aDate); + calcit(aDate.year()); + tDayMap::Iterator it = _days.find(aDate); + if (it!=_days.end()) { + ret+=*it; + } + + return ret; +} + +QStringList ChrisHoliday::entries(unsigned year, unsigned month, unsigned day) +{ + return entries(QDate(year,month,day)); +} + +void ChrisHoliday::calcit(int year) +{ + if (year==_lastyear) return; + _lastyear = year; + _days.clear(); + calc_easter(); + calc_christmas(); +} + +void ChrisHoliday::calc_christmas() +{ + QDate cday(_lastyear,12,24); + int diff; + if ( (diff=cday.dayOfWeek())!=7) { + cday=cday.addDays(-diff); + _days[cday].append(QObject::tr("4. Advent","holidays")); + } + _days[cday.addDays(-7)].append(QObject::tr("3. Advent","holidays")); + _days[cday.addDays(-14)].append(QObject::tr("2. Advent","holidays")); + _days[cday.addDays(-21)].append(QObject::tr("1. Advent","holidays")); +} + +void ChrisHoliday::calc_easter() +{ + unsigned long n = 0; + unsigned long p = 0; + + if ( _lastyear > 1582 ) { + unsigned long a = _lastyear%19; + unsigned long b = _lastyear/100; + unsigned long c = _lastyear%100; + unsigned long d = b/4; + unsigned long e = b%4; + unsigned long f = (b+8)/25; + unsigned long g = (b+f+1)/3; + unsigned long h = (19*a+b-d-g+15)%30; + unsigned long i = c/4; + unsigned long j = c%4; + unsigned long k = j%100; + unsigned long l = (32+2*e+2*i-h-k)%7; + unsigned long m = (a+11*h+22*l)/451; + n = (h+l-7*m+114)/31; + p = (h+l-7*m+114)%31; + } else { + unsigned long a = _lastyear%4; + unsigned long b = _lastyear%7; + unsigned long c = _lastyear%19; + unsigned long d = (19*c+15)%30; + unsigned long e = (2*a+4*b-d+34)%7; + n = (d+e+114)/31; + p = (d+e+114)%31; + } + p++; + QDate d(_lastyear,n,p); + _days[d].append(QObject::tr("Eastersunday","holidays")); + _days[d.addDays(49)].append(QObject::tr("Whitsunday","holidays")); + _days[d.addDays(50)].append(QObject::tr("Whitmonday","holidays")); + _days[d.addDays(39)].append(QObject::tr("Ascension Day","holidays")); + _days[d.addDays(-46)].append(QObject::tr("Ash Wednesday","holidays")); + _days[d.addDays(60)].append(QObject::tr("Corpus Christi","holidays")); +} + +QMap<QDate,QStringList> ChrisHoliday::entries(const QDate&,const QDate&) +{ + QMap<QDate,QStringList> ret; + return ret; +} + +EXPORT_HOLIDAY_PLUGIN(ChrisHoliday); diff --git a/core/pim/datebook/holiday/christian/chrisholiday.h b/core/pim/datebook/holiday/christian/chrisholiday.h index 8dcf4c6..9ae500e 100644 --- a/core/pim/datebook/holiday/christian/chrisholiday.h +++ b/core/pim/datebook/holiday/christian/chrisholiday.h @@ -1,33 +1,33 @@ -#ifndef __DUMMY_HOLIDAY_H
-#define __DUMMY_HOLIDAY_H
-
-#include "hlist.h"
-
-#include <opie2/oholidayplugin.h>
-#include <opie2/oholidaypluginif.h>
-
-#include <qmap.h>
-
-class ChrisHoliday:public Opie::Datebook::HolidayPlugin
-{
-typedef QMap<QDate,QStringList> tDayMap;
-
-public:
- ChrisHoliday():Opie::Datebook::HolidayPlugin(){_lastyear=0;}
- virtual ~ChrisHoliday(){}
-
- virtual QString description();
- virtual QStringList entries(const QDate&);
- virtual QStringList entries(unsigned year, unsigned month, unsigned day);
- virtual QMap<QDate,QStringList> entries(const QDate&,const QDate&);
-protected:
- HList _internallist;
- unsigned int _lastyear;
- tDayMap _days;
-
- void calcit(int year);
- void calc_easter();
- void calc_christmas();
-};
-
-#endif
+#ifndef __DUMMY_HOLIDAY_H +#define __DUMMY_HOLIDAY_H + +#include "hlist.h" + +#include <opie2/oholidayplugin.h> +#include <opie2/oholidaypluginif.h> + +#include <qmap.h> + +class ChrisHoliday:public Opie::Datebook::HolidayPlugin +{ +typedef QMap<QDate,QStringList> tDayMap; + +public: + ChrisHoliday():Opie::Datebook::HolidayPlugin(){_lastyear=0;} + virtual ~ChrisHoliday(){} + + virtual QString description(); + virtual QStringList entries(const QDate&); + virtual QStringList entries(unsigned year, unsigned month, unsigned day); + virtual QMap<QDate,QStringList> entries(const QDate&,const QDate&); +protected: + HList _internallist; + unsigned int _lastyear; + tDayMap _days; + + void calcit(int year); + void calc_easter(); + void calc_christmas(); +}; + +#endif diff --git a/core/pim/datebook/holiday/christian/hlist.cpp b/core/pim/datebook/holiday/christian/hlist.cpp index 795b075..2ce13f5 100644 --- a/core/pim/datebook/holiday/christian/hlist.cpp +++ b/core/pim/datebook/holiday/christian/hlist.cpp @@ -1,18 +1,18 @@ -#include "hlist.h"
-
-#include <qobject.h>
-
-const QStringList HList::entries(const QDate&aDate)const
-{
- QStringList ret;
- if (aDate.month()==12) {
- if (aDate.day()==24) {
- ret.append(QObject::tr("Christmas","holidays"));
- }
- } else if (aDate.month()==1) {
- if (aDate.day()==1) {
- ret.append(QObject::tr("New year","holidays"));
- }
- }
- return ret;
-}
+#include "hlist.h" + +#include <qobject.h> + +const QStringList HList::entries(const QDate&aDate)const +{ + QStringList ret; + if (aDate.month()==12) { + if (aDate.day()==24) { + ret.append(QObject::tr("Christmas","holidays")); + } + } else if (aDate.month()==1) { + if (aDate.day()==1) { + ret.append(QObject::tr("New Year","holidays")); + } + } + return ret; +} diff --git a/core/pim/datebook/holiday/christian/hlist.h b/core/pim/datebook/holiday/christian/hlist.h index 5904852..5a87c50 100644 --- a/core/pim/datebook/holiday/christian/hlist.h +++ b/core/pim/datebook/holiday/christian/hlist.h @@ -1,16 +1,16 @@ -#ifndef _HLIST_H
-#define _HLIST_H
-
-#include <qstringlist.h>
-#include <qdatetime.h>
-
-class HList
-{
-public:
- HList(){};
- virtual ~HList(){};
-
- const QStringList entries(const QDate&)const;
-};
-
-#endif
+#ifndef _HLIST_H +#define _HLIST_H + +#include <qstringlist.h> +#include <qdatetime.h> + +class HList +{ +public: + HList(){}; + virtual ~HList(){}; + + const QStringList entries(const QDate&)const; +}; + +#endif |