From 460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- korganizer/plugins/hebrew/Makefile.am | 16 ++ korganizer/plugins/hebrew/README | 12 + korganizer/plugins/hebrew/configdialog.cpp | 91 ++++++ korganizer/plugins/hebrew/configdialog.h | 49 ++++ korganizer/plugins/hebrew/converter.cpp | 345 +++++++++++++++++++++++ korganizer/plugins/hebrew/converter.h | 75 +++++ korganizer/plugins/hebrew/hebrew.cpp | 112 ++++++++ korganizer/plugins/hebrew/hebrew.desktop | 101 +++++++ korganizer/plugins/hebrew/hebrew.h | 47 ++++ korganizer/plugins/hebrew/holiday.cpp | 431 +++++++++++++++++++++++++++++ korganizer/plugins/hebrew/holiday.h | 46 +++ korganizer/plugins/hebrew/parsha.cpp | 273 ++++++++++++++++++ korganizer/plugins/hebrew/parsha.h | 33 +++ 13 files changed, 1631 insertions(+) create mode 100644 korganizer/plugins/hebrew/Makefile.am create mode 100644 korganizer/plugins/hebrew/README create mode 100644 korganizer/plugins/hebrew/configdialog.cpp create mode 100644 korganizer/plugins/hebrew/configdialog.h create mode 100644 korganizer/plugins/hebrew/converter.cpp create mode 100644 korganizer/plugins/hebrew/converter.h create mode 100644 korganizer/plugins/hebrew/hebrew.cpp create mode 100644 korganizer/plugins/hebrew/hebrew.desktop create mode 100644 korganizer/plugins/hebrew/hebrew.h create mode 100644 korganizer/plugins/hebrew/holiday.cpp create mode 100644 korganizer/plugins/hebrew/holiday.h create mode 100644 korganizer/plugins/hebrew/parsha.cpp create mode 100644 korganizer/plugins/hebrew/parsha.h (limited to 'korganizer/plugins/hebrew') diff --git a/korganizer/plugins/hebrew/Makefile.am b/korganizer/plugins/hebrew/Makefile.am new file mode 100644 index 000000000..4f48cc58b --- /dev/null +++ b/korganizer/plugins/hebrew/Makefile.am @@ -0,0 +1,16 @@ +# $Id$ + +METASOURCES = AUTO + +INCLUDES = -I$(top_srcdir)/korganizer/interfaces $(all_includes) + +kde_module_LTLIBRARIES = libkorg_hebrew.la + +libkorg_hebrew_la_SOURCES = hebrew.cpp configdialog.cpp holiday.cpp parsha.cpp converter.cpp +libkorg_hebrew_la_LDFLAGS = -module $(KDE_PLUGIN) $(KDE_RPATH) $(all_libraries) +libkorg_hebrew_la_LIBADD = $(LIB_KDECORE) $(LIB_KDEUI) + +noinst_HEADERS = hebrew.h configdialog.h parsha.h converter.h holiday.h + +servicedir = $(kde_servicesdir)/korganizer +service_DATA = hebrew.desktop diff --git a/korganizer/plugins/hebrew/README b/korganizer/plugins/hebrew/README new file mode 100644 index 000000000..297df67fb --- /dev/null +++ b/korganizer/plugins/hebrew/README @@ -0,0 +1,12 @@ +Jewish calendar plugin for KOrganizer, by Jonathan Singer + +Note that it only applies to modern (Gregorian) dates, as KDE/Qt does not +support Julian dates. See my KLuach application +if you want to look up historical dates. + +TRANSLATORS! The weird-looking text strings are the names of Jewish months, +holidays and whatnot. They aren't translateable (although European or Near +Eastern languages may spell them differently) and should usually just be changed +into local characters with the same sound. "I" and "II" are Roman numerals. + +Date routines from Jewish Calendar by Frank Yellin diff --git a/korganizer/plugins/hebrew/configdialog.cpp b/korganizer/plugins/hebrew/configdialog.cpp new file mode 100644 index 000000000..aad50a680 --- /dev/null +++ b/korganizer/plugins/hebrew/configdialog.cpp @@ -0,0 +1,91 @@ +/* + This file is part of KOrganizer. + Copyright (c) 2003 Jonathan Singer + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +#include "configdialog.h" +#include "configdialog.moc" +#include +#include +#include +#include +#include +#include +#include + +ConfigDialog::ConfigDialog(QWidget * parent):KDialogBase(Plain, i18n("Configure Holidays"), Ok|Cancel, Ok, + parent) +{ + QFrame *topFrame = plainPage(); + QVBoxLayout *topLayout = + new QVBoxLayout(topFrame, 0, spacingHint()); + + israel_box = new QCheckBox(topFrame); + israel_box->setText(i18n("Use Israeli holidays")); + topLayout->addWidget(israel_box); + + parsha_box = new QCheckBox(topFrame); + parsha_box->setText(i18n("Show weekly parsha")); + topLayout->addWidget(parsha_box); + + omer_box = new QCheckBox(topFrame); + omer_box->setText(i18n("Show day of Omer")); + topLayout->addWidget(omer_box); + + chol_box = new QCheckBox(topFrame); + chol_box->setText(i18n("Show Chol HaMoed")); + topLayout->addWidget(chol_box); + + load(); +} + +ConfigDialog::~ConfigDialog() +{ +} + +void ConfigDialog::load() +{ + KConfig config("korganizerrc", true, false); // Open read-only, no kdeglobals + + config.setGroup("Calendar/Hebrew Calendar Plugin"); + israel_box->setChecked(config. + readBoolEntry("Israel", + (KGlobal::locale()-> + country() == ".il"))); + parsha_box->setChecked(config.readBoolEntry("Parsha", true)); + chol_box->setChecked(config.readBoolEntry("Chol_HaMoed", true)); + omer_box->setChecked(config.readBoolEntry("Omer", true)); + +} + +void ConfigDialog::save() +{ + KConfig config("korganizerrc", false, false); // Open read-write, no kdeglobals + + config.setGroup("Calendar/Hebrew Calendar Plugin"); + config.writeEntry("Israel", israel_box->isChecked()); + config.writeEntry("Parsha", parsha_box->isChecked()); + config.writeEntry("Chol_HaMoed", chol_box->isChecked()); + config.writeEntry("Omer", omer_box->isChecked()); + config.sync(); +} + +void ConfigDialog::slotOk() +{ + save(); + + accept(); +} diff --git a/korganizer/plugins/hebrew/configdialog.h b/korganizer/plugins/hebrew/configdialog.h new file mode 100644 index 000000000..1d0d18115 --- /dev/null +++ b/korganizer/plugins/hebrew/configdialog.h @@ -0,0 +1,49 @@ +/* + This file is part of KOrganizer. + Copyright (c) 2003 Jonathan Singer + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +#ifndef CONFIGDIALOG_H +#define CONFIGDIALOG_H + +#include +#include + +/** +@author Jonathan Singer +*/ +class ConfigDialog:public KDialogBase +{ +Q_OBJECT public: + + ConfigDialog(QWidget * parent = 0); + virtual ~ ConfigDialog(); + +protected: + void load(); + void save(); + + protected slots: void slotOk(); + +private: + QCheckBox * omer_box; + QCheckBox *parsha_box; + QCheckBox *israel_box; + QCheckBox *chol_box; + +}; + +#endif diff --git a/korganizer/plugins/hebrew/converter.cpp b/korganizer/plugins/hebrew/converter.cpp new file mode 100644 index 000000000..1381292e6 --- /dev/null +++ b/korganizer/plugins/hebrew/converter.cpp @@ -0,0 +1,345 @@ +/*************************************************************************** + * Copyright (C) 2003 by Jonathan Singer * + * jsinger@leeta.net * + * Calendar routines from Hebrew Calendar by Frank Yellin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ +#include "converter.h" +#include + +Converter::Converter() +{ + +} + +Converter::~Converter() +{ +} + +long Converter::absolute_from_gregorian(int year, int month, int day) +{ + int xyear, day_number; + + xyear = year - 1; + day_number = day + 31 * (month - 1); + if (month > 2) + { + day_number -= (23 + (4 * month)) / 10; + if (gregorian_leap_year_p(year)) + day_number++; + } + return day_number + /* the day number within the current year */ + 365L * xyear + /* days in prior years */ + (xyear / 4) + /* Julian leap years */ + (-(xyear / 100)) + /* deduct century years */ + (xyear / 400); /* add Gregorian leap years */ +} + +/* Given a Hebrew date, calculate the number of days since + * January 0, 0001, Gregorian + */ +long Converter::absolute_from_hebrew(int year, int month, int day) +{ + long sum = day + hebrew_elapsed_days(year) - 1373429L; + int i; + + if (month < 7) + { + int months = hebrew_months_in_year(year); + + for (i = 7; i <= months; ++i) + sum += hebrew_month_length(year, i); + for (i = 1; i < month; ++i) + sum += hebrew_month_length(year, i); + } + else + { + for (i = 7; i < month; ++i) + sum += hebrew_month_length(year, i); + } + return sum; +} + +/* Given an absolute date, calculate the gregorian date */ +void + Converter::gregorian_from_absolute(long date, int *yearp, + int *monthp, int *dayp) +{ + int year, month, day; + + for (year = date / 366; + date >= absolute_from_gregorian(year + 1, 1, 1); ++year) ; + for (month = 1; + (month <= 11) + && (date >= absolute_from_gregorian(year, 1 + month, 1)); + ++month ) ; + day = 1 + date - absolute_from_gregorian(year, month, 1); + *yearp = year; + *monthp = month; + *dayp = day; +} + +/* Given an absolute date, calculate the Hebrew date */ +void + Converter::hebrew_from_absolute(long date, int *yearp, int *monthp, + int *dayp) +{ + int year, month, day, gyear, gmonth, gday, months; + + gregorian_from_absolute(date, &gyear, &gmonth, &gday); + year = gyear + 3760; + while (date >= absolute_from_hebrew(1 + year, 7, 1)) + year++; + months = hebrew_months_in_year(year); + for (month = 7; + date > absolute_from_hebrew(year, month, + hebrew_month_length(year, month)); + month = 1 + (month % months)) ; + day = 1 + date - absolute_from_hebrew(year, month, 1); + *yearp = year; + *monthp = month; + *dayp = day; +} + +/* Number of months in a Hebrew year */ +int Converter::hebrew_months_in_year(int year) +{ + if (hebrew_leap_year_p(year)) + return 13; + else + return 12; +} + +enum +{ Nissan = + 1, Iyar, Sivan, Tamuz, Ab, Elul, Tishrei, Cheshvan, Kislev, Tevet, + Shvat, Adar, AdarII, AdarI = 12 +}; + +enum +{ January = + 1, February, March, April, May, June, July, August, September, + October, November, December +}; + +/* Number of days in a Hebrew month */ +int Converter::hebrew_month_length(int year, int month) +{ + switch (month) + { + case Tishrei: + case Shvat: + case Nissan: + case Sivan: + case Ab: + return 30; + + case Tevet: + case Iyar: + case Tamuz: + case Elul: + case AdarII: + return 29; + + case Cheshvan: + // 29 days, unless it's a long year. + if ((hebrew_year_length(year) % 10) == 5) + return 30; + else + return 29; + + case Kislev: + // 30 days, unless it's a short year. + if ((hebrew_year_length(year) % 10) == 3) + return 29; + else + return 30; + + case Adar: + // Adar (non-leap year) has 29 days. Adar I has 30 days. + if (hebrew_leap_year_p(year)) + return 30; + else + return 29; + + default: + return 0; + } +} + +/* Number of days in a Julian or gregorian month */ +int + Converter::secular_month_length(int year, + int month /*, bool julianp */ ) +{ + switch (month) + { + case January: + case March: + case May: + case July: + case August: + case October: + case December: + return 31; + case April: + case June: + case September: + case November: + return 30; + case February: + if (gregorian_leap_year_p(year)) + return 29; + else + return 28; + default: + return 0; + } +} + +/* Is it a Leap year in the gregorian calendar */ +bool Converter::gregorian_leap_year_p(int year) +{ + if ((year % 4) != 0) + return 0; + if ((year % 400) == 0) + return 1; + if ((year % 100) == 0) + return 0; + return 1; +} + +/* Is it a leap year in the Jewish Calendar */ +bool Converter::hebrew_leap_year_p(int year) +{ + switch (year % 19) + { + case 0: + case 3: + case 6: + case 8: + case 11: + case 14: + case 17: + return 1; + default: + return 0; + } +} + +/* Return the number of days from 1 Tishrei 0001 to the beginning of the given year. + * Since this routine gets called frequently with the same year arguments, we cache + * the most recent values. + */ +#define MEMORY 5 +long Converter::hebrew_elapsed_days(int year) +{ + static int saved_year[MEMORY] = { -1, -1, -1, -1, -1 }; + static long saved_value[MEMORY]; + int i; + + for (i = 0; i < MEMORY; ++i) + if (year == saved_year[i]) + return saved_value[i]; + for (i = 0; i < MEMORY-1; ++i) { + saved_year[i] = saved_year[1 + i]; + saved_value[i] = saved_value[1 + i]; + } + saved_year[MEMORY - 1] = year; + saved_value[MEMORY - 1] = hebrew_elapsed_days2(year); + return saved_value[MEMORY - 1]; +} + +long Converter::hebrew_elapsed_days2(int year) +{ + long prev_year = year - 1; + long months_elapsed = 235L * (prev_year / 19) /* months in complete cycles so far */ + + 12L * (prev_year % 19) /* regular months in this cycle */ + + (((prev_year % 19) * 7 + 1) / 19); /* leap months this cycle */ + long parts_elapsed = 5604 + 13753 * months_elapsed; + long day = 1 + 29 * months_elapsed + parts_elapsed / 25920; + long parts = parts_elapsed % 25920; + int weekday = (day % 7); + long alt_day = ((parts >= 19440) + || (weekday == 2 && (parts >= 9924) + && !hebrew_leap_year_p(year)) || (weekday == 1 + && (parts >= + 16789) + && + hebrew_leap_year_p + (prev_year))) + ? day + 1 : day; + switch (alt_day % 7) + { + case 0: + case 3: + case 5: + return 1 + alt_day; + default: + return alt_day; + } +} + +/* Number of days in the given Hebrew year */ +int Converter::hebrew_year_length(int year) +{ + return hebrew_elapsed_days(1 + year) - hebrew_elapsed_days(year); +} + +/* Fill in the DateResult structure based on the given secular date */ +void + Converter::SecularToHebrewConversion(int syear, int smonth, + int sday, + struct DateResult *result) +{ + int hyear, hmonth, hday; + long absolute; + + absolute = absolute_from_gregorian(syear, smonth, sday); + + hebrew_from_absolute(absolute, &hyear, &hmonth, &hday); + + result->year = hyear; + result->month = hmonth; + result->day = hday; + finish_up(absolute, hyear, hmonth, syear, smonth, result); +} + +/* Fill in the DateResult structure based on the given Hebrew date */ +void + Converter::HebrewToSecularConversion(int hyear, int hmonth, + int hday, + struct DateResult *result) +{ + int syear, smonth, sday; + long absolute; + + absolute = absolute_from_hebrew(hyear, hmonth, hday); + gregorian_from_absolute(absolute, &syear, &smonth, &sday); + result->year = hyear; + result->month = hmonth; + result->day = hday; + finish_up(absolute, hyear, hmonth, syear, smonth, result); +} + +/* This is common code for filling up the DateResult structure */ +void + Converter::finish_up(long absolute, int hyear, int hmonth, + int syear, int smonth, + struct DateResult *result) +{ + result->hebrew_month_length = hebrew_month_length(hyear, hmonth); + result->secular_month_length = secular_month_length(syear, smonth); + result->hebrew_leap_year_p = hebrew_leap_year_p(hyear); + result->secular_leap_year_p = gregorian_leap_year_p(syear); + result->kvia = (hebrew_year_length(hyear) % 10) - 3; + // absolute is -1 on 1/1/0001 Julian + result->day_of_week = (7 + absolute) % 7; + result->hebrew_day_number = + absolute - absolute_from_hebrew(hyear, 7, 1) + 1; + +} diff --git a/korganizer/plugins/hebrew/converter.h b/korganizer/plugins/hebrew/converter.h new file mode 100644 index 000000000..8a3bc8baf --- /dev/null +++ b/korganizer/plugins/hebrew/converter.h @@ -0,0 +1,75 @@ +/*************************************************************************** + * Copyright (C) 2003 by Jonathan Singer * + * jsinger@leeta.net * + * Calendar routines from Hebrew Calendar by Frank Yellin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ +#ifndef CONVERTER_H +#define CONVERTER_H + +#include +#include + +struct DateResult +{ + int year; + int month; + int day; + int day_of_week; + + int hebrew_month_length, secular_month_length; + bool hebrew_leap_year_p, secular_leap_year_p; + int kvia; + int hebrew_day_number; +}; + +/** +@author Jonathan Singer +*/ +class Converter +{ +public: + + Converter(); + ~Converter(); + + static bool hebrew_leap_year_p(int year); + static bool gregorian_leap_year_p(int year); + + static long absolute_from_gregorian(int year, int month, int day); + static long absolute_from_hebrew(int year, int month, int day); + + static void gregorian_from_absolute(long date, int *yearp, + int *monthp, int *dayp); + static void hebrew_from_absolute(long date, int *yearp, int *monthp, + int *dayp); + + static int hebrew_months_in_year(int year); + static int hebrew_month_length(int year, int month); + static int secular_month_length(int year, int month); + + static long hebrew_elapsed_days(int year); + static long hebrew_elapsed_days2(int year); + static int hebrew_year_length(int year); + + static void finish_up(long absolute, int hyear, int hmonth, + int syear, int smonth, + struct DateResult *result); + + static void SecularToHebrewConversion(int year, int month, int day, + struct DateResult *result); + static void HebrewToSecularConversion(int year, int month, int day, + struct DateResult *result); + +private: + + static QStringList HebrewMonthNames; + static QStringList SecularMonthNames; + +}; + +#endif diff --git a/korganizer/plugins/hebrew/hebrew.cpp b/korganizer/plugins/hebrew/hebrew.cpp new file mode 100644 index 000000000..4c557d00d --- /dev/null +++ b/korganizer/plugins/hebrew/hebrew.cpp @@ -0,0 +1,112 @@ +/* + This file is part of KOrganizer. + Copyright (c) 2003 Jonathan Singer + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include +#include +#include +#include +#include +#include +#include "hebrew.h" +#include "configdialog.h" +#include "parsha.h" +#include "converter.h" +#include "holiday.h" + +bool Hebrew::IsraelP; + +class HebrewFactory:public CalendarDecorationFactory +{ +public: + CalendarDecoration * create() + { + return new Hebrew; + } +}; + +K_EXPORT_COMPONENT_FACTORY( libkorg_hebrew, HebrewFactory ) + + +QString Hebrew::shortText(const QDate & date) +{ + + KConfig config("korganizerrc", true, false); // Open read-only, no kdeglobals + + config.setGroup("Calendar/Hebrew Calendar Plugin"); + IsraelP = + config.readBoolEntry("Israel", + (KGlobal::locale()->country() == ".il")); + Holiday::ParshaP = config.readBoolEntry("Parsha", true); + Holiday::CholP = config.readBoolEntry("Chol_HaMoed", true); + Holiday::OmerP = config.readBoolEntry("Omer", true); + QString *label_text = new QString(); + + int day = date.day(); + int month = date.month(); + int year = date.year(); + + // core calculations!! + struct DateResult result; + + Converter::SecularToHebrewConversion(year, month, day, /*0, */ + &result); + int hebrew_day = result.day; + int hebrew_month = result.month; + int hebrew_year = result.year; + int hebrew_day_of_week = result.day_of_week; + bool hebrew_leap_year_p = result.hebrew_leap_year_p; + int hebrew_kvia = result.kvia; + int hebrew_day_number = result.hebrew_day_number; + + QStringList holidays = + Holiday::FindHoliday(hebrew_month, hebrew_day, + hebrew_day_of_week + 1, hebrew_kvia, + hebrew_leap_year_p, IsraelP, + hebrew_day_number, hebrew_year); + + KCalendarSystem *cal = KCalendarSystemFactory::create("hebrew"); + *label_text = QString("%1 %2").arg(cal->dayString(date, false)) + .arg(cal->monthName(date)); + + if (holidays.count()) + { + int count = holidays.count(); + + for (int h = 0; h <= count; ++h) + { + *label_text += "\n" + holidays[h]; + } + } + + return *label_text; +} + +QString Hebrew::info() +{ + return + i18n("This plugin provides the date in the Jewish calendar."); +} + +void Hebrew::configure(QWidget * parent) +{ + ConfigDialog *dlg = new ConfigDialog(parent); //parent? + + dlg->exec(); + delete dlg; +} diff --git a/korganizer/plugins/hebrew/hebrew.desktop b/korganizer/plugins/hebrew/hebrew.desktop new file mode 100644 index 000000000..86c88328d --- /dev/null +++ b/korganizer/plugins/hebrew/hebrew.desktop @@ -0,0 +1,101 @@ +[Desktop Entry] +X-KDE-Library=libkorg_hebrew +Name=Jewish Calendar Plugin +Name[af]=Joodse kalender inprop module +Name[bg]=Приставка за еврейския календар +Name[br]=Lugent deiziadur yudev +Name[bs]=Dodatak za hebrejski kalendar +Name[ca]=Endollable de calendari jueu +Name[cs]=Modul židovského kalendáře +Name[da]=Jødisk kalender-plugin +Name[de]=Modul für jüdischen Kalender +Name[el]=Πρόσθετο εβραϊκού ημερολογίου +Name[eo]=Judkalendar-kromaĵo +Name[es]=Accesorio de calendario judío +Name[et]=Juudi kalendri plugin +Name[eu]=Egutegi judutar plugin-a +Name[fa]=وصلۀ تقویم یهودی +Name[fi]=Juutalaisen kalenterin laajennus +Name[fr]=Module de prise en charge du calendrier juif +Name[fy]=Joadske kalenderplugin +Name[gl]=Extensión para Calendario Xudeu +Name[hu]=Bővítőmodul a zsidó naptár kezeléséhez +Name[is]=Gyðinga dagatalsíforrit +Name[it]=Plugin calendario ebraico +Name[ja]=ユダヤ歴カレンダープラグイン +Name[ka]=ებრაული კალენდრის მოდული +Name[kk]=Яһуди күнтізбесінің модулі +Name[km]=កម្មវិធី​ជំនួយ​ប្រតិទិន Jewish +Name[lt]=Žydų kalendoriaus priedas +Name[mk]=Приклучок за еврејски календар +Name[ms]=PLugin Kalender Yahudi +Name[nb]=Programtillegg for jødisk kalender +Name[nds]=Moduul för juudschen Kalenner +Name[ne]=यहूदि क्यालेन्डर प्लगइन +Name[nl]=Joodse kalenderplugin +Name[nn]=Programtillegg for jødisk kalender +Name[pl]=Wtyczka kalendarza żydowskiego +Name[pt]='Plugin' do Calendário Judeu +Name[pt_BR]=Plug-in de Calendário Judaico +Name[ru]=Еврейский календарь +Name[sk]=Modul Židovského kalendára +Name[sl]=Vstavek za židovski koledar +Name[sr]=Прикључак календара за јеврејски календар +Name[sr@Latn]=Priključak kalendara za jevrejski kalendar +Name[sv]=Insticksprogram för judisk kalender +Name[ta]=ஜூவிஷ் நாள்காட்டி சொருகுப்பொருள் +Name[tg]=Тақвимоти яҳудӣ +Name[tr]=İbrani Takvimi Eklentisi +Name[uk]=Втулок єврейського календаря +Name[zh_CN]=犹太教日历插件 +Name[zh_TW]=猶太行事曆外掛程式 +Comment=Shows all dates in korganizer also in the Jewish calendar system. +Comment[af]=Vertoon alle datums in KOrganizer ook volgens die Joodse kalender. +Comment[bg]=Приставката служи за показване на датите според еврейския календар. +Comment[ca]=Mostra totes les dates del korganizer també en el sistema del calendari jueu. +Comment[cs]=Zobrazení všech dat v korganizeru také v židovském kalendáři. +Comment[da]=Viser alle datoer i korganizer også i det jødiske kalendersystem. +Comment[de]=Zeigt alle Daten in KOrganizer auch im jüdischen Kalendarium an. +Comment[el]=Εμφανίζει όλες τις ημερομηνίες στο korganizer και στο εβραϊκό ημερολογιακό σύστημα. +Comment[es]=Muestra todas las fechas de korganizer también en el sistema de calendario judío. +Comment[et]=Näitab KOrganizeris kõiki kuupäevi ka juudi kalendri järgi. +Comment[eu]=korganizer-en data guztiak egutegi judutar sisteman ere erakusten ditu. +Comment[fa]=همۀ تاریخهای korganizer، همچنین سیستم تقویم یهودی را نمایش می‌دهد. +Comment[fi]=Näyttää kaikki päivät KOrganizerissa myös Juutalaisen kalenterijärjestelmän mukaan. +Comment[fr]=Affiche toutes les dates de KOrganizer selon le calendrier Juif +Comment[fy]=Lit alle datums yn KOrganizer ek yn it Joadske kalinderssysteem sjen. +Comment[gl]=Amosa todas as datas en korganizer, tamén o sistema de calendario xudeu. +Comment[he]=מציג את כל התאריכים בארגונית גם בלוח השנה העברי +Comment[hu]=A KOrganizer dátumait kiírja a hagyományos zsidó naptár szerint is. +Comment[is]=Sýna alla dagsetningar í KOrganizer sem eru einnig í dagatali gyðinga. +Comment[it]=Mostra tutte le date in korganizer secondo il calendario ebraico. +Comment[ja]=korganizer のすべての日付をユダヤ暦でも表示します。 +Comment[ka]=ყველა თარიღს ებრაული კალენდრის მიხედვითაც აჩვენებს +Comment[kk]=Яһуди күнтізбе күндерін korganizer-де көрсететін модулі. +Comment[km]=បង្ហាញ​កាលបរិច្ឆេទ​ទាំងអស់​ក្នុង korganizer នៅ​ក្នុង​ប្រព័ន្ធ​ប្រតិទិន Jewish ។ +Comment[lt]=Rodo visas dienas kalendoriuje taip pat ir žydų kalendoriaus sistema. +Comment[mk]=Ги прикажува сите датуми во КОрганизатор и според еврејскиот календар. +Comment[ms]=Memaparkan semua tarikh dalam korganizer dan juga dalam sistem kalendar Yahudi. +Comment[nb]=Viser alle datoer i korganizer også i det jødiske kalendersystemet. +Comment[nds]=Wiest all Daten binnen KOrganizer ok in den juudschen Kalenner. +Comment[ne]=केडीई आयोजकमा पनि सबै मिति यहूदि क्यालेन्डर प्रणालीमा देखाउछ । +Comment[nl]=Toont alle data in KOrganizer ook in het Joodse kalendersysteem. +Comment[nn]=Viser alle datoane i KOrganizer i den jødiske kalenderen. +Comment[pl]=Pokazuje wszystkie daty w KOrganizerze również w kalendarzu żydowskim. +Comment[pt]=Mostra todas as datas no KOrganizer também no sistema de calendários Judeu. +Comment[pt_BR]=Mostra todas as datas no KOrganizer também no sistema de calendário judaico +Comment[ru]=Показывать все даты по еврейскому календарю. +Comment[sk]=Zobrazí všetky dátumy v korganizer tiež aj židovskom kalendári. +Comment[sl]=Prikaže vse datume v KOrganizerju; tudi v židovskem koledarskem sistemu. +Comment[sr]=Приказује све датуме у KOrganizer-у и по јеврејском календарском систему. +Comment[sr@Latn]=Prikazuje sve datume u KOrganizer-u i po jevrejskom kalendarskom sistemu. +Comment[sv]=Visar också alla datum i Korganizer enligt den judiska kalendern. +Comment[ta]=korganizer மற்றும் ஜேவிஷ் நாட்காட்டி அமைப்பில் ல் உள்ள எல்லா தேதிகளையும் காட்டுகிறது. +Comment[tr]=KOrganizer'da tüm tarihleri İbrani takvimine göre gösterir. +Comment[uk]=Показує всі дати в korganizer також і в системі єврейського календаря. +Comment[zh_CN]=在 KOrganizer 中显示犹太教日历系统的全部日期。 +Comment[zh_TW]=顯示所有猶太行事曆的日期 +Type=Service +ServiceTypes=Calendar/Plugin,Calendar/Decoration +X-KDE-KOrganizer-HasSettings=true +X-KDE-PluginInterfaceVersion=2 diff --git a/korganizer/plugins/hebrew/hebrew.h b/korganizer/plugins/hebrew/hebrew.h new file mode 100644 index 000000000..1153c1012 --- /dev/null +++ b/korganizer/plugins/hebrew/hebrew.h @@ -0,0 +1,47 @@ +/* + This file is part of KOrganizer. + Copyright (c) 2003 Jonathan Singer + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +#ifndef KORG_HEBREW_H +#define KORG_HEBREW_H + +#include +#include +#include + +using namespace KOrg; + +class Hebrew:public CalendarDecoration +{ +public: + Hebrew() + { + } + ~Hebrew() + { + } + void configure(QWidget * parent); + QString shortText(const QDate &); + + QString info(); + static bool IsraelP; + +private: + +}; + +#endif diff --git a/korganizer/plugins/hebrew/holiday.cpp b/korganizer/plugins/hebrew/holiday.cpp new file mode 100644 index 000000000..732a00447 --- /dev/null +++ b/korganizer/plugins/hebrew/holiday.cpp @@ -0,0 +1,431 @@ +/*************************************************************************** + * Copyright (C) 2003 by Jonathan Singer * + * jsinger@leeta.net * + * Calendar routines from Hebrew Calendar by Frank Yellin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ +#include "holiday.h" +#include + +bool Holiday::CholP; +bool Holiday::OmerP; +bool Holiday::ParshaP; + +QStringList Holiday::holidays; +int Holiday::HolidayFlags; + +Holiday::Holiday() +{ + +} + +Holiday::~Holiday() +{ +} + +/* Given a day of the Hebrew month, figuring out all the interesting holidays that +* correspond to that date. ParshaP, OmerP, and CholP determine whether we should +* given info about the Parsha of the week, the Sfira, or Chol Hamoed. +* +* We are also influenced by the IsraelP flag +*/ + +QStringList + Holiday::FindHoliday(int month, int day, int weekday, int kvia, + bool leap_year_p, bool israel_p, + int day_number, int year) +{ + + enum + { Sunday = 1, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday + }; + + holidays.clear(); + bool shabbat_p = (weekday == Saturday); // Is it a Saturday? + + // Treat Adar in a non-leap year as if it were Adar II. + if ((month == 12) && !leap_year_p) + month = 13; + switch (month) + { + case 1: /* Nissan */ + switch (day) + { + case 1: + if (shabbat_p) + holidays << + i18n + ("These are Jewish holidays and mostly do not have translations. They may have different spellings in your language; otherwise, just translate the sound to your characters", + "Sh. HaHodesh"); + break; + case 14: + if (!shabbat_p) + // If it's Shabbat, we have three pieces of info. + // This is the least important. + holidays << i18n("Erev Pesach"); + /* Fall thru */ + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + // The Saturday before Pesach (8th-14th) + if (shabbat_p) + holidays << i18n("Sh. HaGadol"); + break; + case 15: + case 16: + case 21: + case 22: + if (!israel_p || (day == 15) || (day == 21)) + { + holidays << i18n("Pesach"); + break; + } + else if (day == 22) + break; + /* else fall through */ + case 17: + case 18: + case 19: + case 20: + if (CholP) + holidays << i18n("Chol Hamoed"); + break; + case 27: + // Yom HaShoah only exists since Israel was established. + if (year > 1948 + 3760) + holidays << i18n("Yom HaShoah"); + break; + } + if ((day > 15) && OmerP) + // Count the Omer, starting after the first day of Pesach. + holidays << Sfirah(day - 15); + break; + + case 2: /* Iyar */ + switch (day) + { + case 2: + case 3: + case 4: + case 5: + // Yom HaAtzmaut is on the 5th, unless that's a Saturday, in which + // case it is moved back two days to Thursday. Yom HaZikaron is + // the day before Yom HaAtzmaut. + if (year >= 1948 + 3760) + { // only after Israel established. + switch (weekday) + { + case Wednesday: + if (day == 5) + holidays << i18n("Yom HaAtzmaut"); + else + holidays << i18n("Yom HaZikaron"); + break; + case Thursday: + // This can't be 2 Iyar. + holidays << i18n("Yom HaAtzmaut"); + break; + case Friday: + case Saturday: + // These are never either of them. + break; + default: + // All other days follow the normal rules. + if (day == 4) + holidays << i18n("Yom HaZikaron"); + else if (day == 5) + holidays << i18n("Yom HaAtzmaut"); + } + } + break; + case 28: + // only since the 1967 war + if (year > 1967 + 3760) + holidays << i18n("Yom Yerushalayim"); + break; + case 18: + holidays << i18n("Lag BaOmer"); + break; + } + if ((day != 18) && OmerP) + // Sfirah the whole month. But Lag BaOmer is already mentioned. + holidays << Sfirah(day + 15); + + break; + + case 3: /* Sivan */ + switch (day) + { + case 1: + case 2: + case 3: + case 4: + // Sfirah until Shavuot + if (OmerP) + holidays << Sfirah(day + 44); + break; + case 5: + // Don't need to mention Sfira(49) if there's already two other + // pieces of information + if (OmerP && !shabbat_p) + holidays << Sfirah(49); + holidays << i18n("Erev Shavuot"); + break; + case 6: + case 7: + if (!israel_p || (day == 6)) + holidays << i18n("Shavuot"); + break; + } + break; + + case 4: /* Tamuz */ + // 17th of Tamuz, except Shabbat pushes it to Sunday. + if ((!shabbat_p && (day == 17)) + || ((weekday == 1) && (day == 18))) + holidays << i18n("Tzom Tammuz"); + break; + + case 5: /* Ab */ + if (shabbat_p && (3 <= day) && (day <= 16)) + // The shabbat before and after Tisha B'Av are special + if (day <= 9) + holidays << i18n("Sh. Hazon"); + else + holidays << i18n("Sh. Nahamu"); + else if ((!shabbat_p && (day == 9)) + || ((weekday == 1) && (day == 10))) + // 9th of Av, except Shabbat pushes it to Sunday. + holidays << i18n("Tisha B'Av"); + break; + + case 6: /* Elul */ + if ((day >= 20) && (day <= 26) && shabbat_p) + holidays << i18n("S'lichot"); + else if (day == 29) + holidays << i18n("Erev R.H."); + break; + + case 7: /* Tishrei */ + switch (day) + { + case 1: + case 2: + holidays << i18n("Rosh Hashana"); + break; + case 3: + if (shabbat_p) + holidays << i18n("Sh. Shuvah"); + else + holidays << i18n("Tzom Gedalia"); + break; + case 4: + if (weekday == 1) + holidays << i18n("Tzom Gedalia"); + /* fall through */ + case 5: + case 6: + case 7: + case 8: + if (shabbat_p) + holidays << i18n("Sh. Shuvah"); + break; + case 9: + holidays << i18n("Erev Y.K."); + break; + case 10: + holidays << i18n("Yom Kippur"); + break; + case 14: + holidays << i18n("Erev Sukkot"); + break; + case 15: + case 16: + if (!israel_p || (day == 15)) + { + holidays << i18n("Sukkot"); + break; + } + /* else fall through */ + case 17: + case 18: + case 19: + case 20: + if (CholP) + holidays << i18n("Chol Hamoed"); + break; + case 21: + holidays << i18n("Hoshana Rabah"); + break; + case 22: + holidays << i18n("Shmini Atzeret"); + break; + case 23: + if (!israel_p) + holidays << i18n("Simchat Torah"); + break; + } + break; + case 8: /* Cheshvan */ + break; + + case 9: /* Kislev */ + if (day == 24) + holidays << i18n("Erev Hanukah"); + else if (day >= 25) + holidays << i18n("Hanukah"); + break; + + case 10: /* Tevet */ + if (day <= (kvia == 0 ? 3 : 2)) + // Need to know length of Kislev to determine last day of Chanukah + holidays << i18n("Hanukah"); + else if (((day == 10) && !shabbat_p) + || ((day == 11) && (weekday == 1))) + // 10th of Tevet. Shabbat pushes it to Sunday + holidays << i18n("Tzom Tevet"); + break; + + case 11: /* Shvat */ + switch (day) + { + // The info for figuring out Shabbat Shirah is from the Gnu code. I + // assume it's correct. +// static char *song = i18n("Sh. Shirah"; + case 10: + if ((kvia != 0) && shabbat_p) + holidays << i18n("Sh. Shirah"); + break; + case 11: + case 12: + case 13: + case 14: + case 16: + if (shabbat_p) + holidays << i18n("Sh. Shirah"); + break; + case 15: + if (shabbat_p) + holidays << i18n("Sh. Shirah"); + holidays << i18n("Tu B'Shvat"); + case 17: + if ((kvia == 0) && shabbat_p) + holidays << i18n("Sh. Shirah"); + break; + case 25: + case 26: + case 27: + case 28: + case 29: + case 30: + // The last shabbat on or before 1 Adar or 1 AdarII + if (shabbat_p && !leap_year_p) + holidays << i18n("Sh. Shekalim"); + break; + } + break; + + case 12: /* Adar I */ + if (day == 14) + // Eat Purim Katan Candy + holidays << i18n("Purim Katan"); + else if ((day >= 25) && shabbat_p) + // The last shabbat on or before 1 Adar II. + holidays << i18n("Sh. Shekalim"); + break; + + case 13: /* Adar II or Adar */ + switch (day) + { + case 1: + if (shabbat_p) + holidays << i18n("Sh. Shekalim"); + break; + case 11: + case 12: + // Ta'anit ester is on the 13th. But shabbat moves it back to + // Thursday. + if (weekday == Thursday) + holidays << i18n("Ta'anit Ester"); + /* Fall thru */ + case 7: + case 8: + case 9: + case 10: + // The Shabbat before purim is Shabbat Zachor + if (shabbat_p) + holidays << i18n("Sh. Zachor"); + break; + case 13: + if (shabbat_p) + holidays << i18n("Sh. Zachor"); + else + holidays << i18n("Erev Purim"); + // It's Ta'anit Esther, unless it's a Friday or Saturday + if (weekday < Friday) + holidays << i18n("Ta'anit Ester"); + break; + case 14: + holidays << i18n("Purim"); + break; + case 15: + if (!shabbat_p) + holidays << i18n("Shushan Purim"); + break; + case 16: + if (weekday == 1) + holidays << i18n("Shushan Purim"); + break; + case 17: + case 18: + case 19: + case 20: + case 21: + case 22: + case 23: + if (shabbat_p) + holidays << i18n("Sh. Parah"); + break; + case 24: + case 25: + case 26: + case 27: + case 28: + case 29: + if (shabbat_p) + holidays << i18n("Sh. HaHodesh"); + break; + } + break; + } + if (shabbat_p && ParshaP) + // Find the Parsha on Shabbat. + holidays << Parsha::FindParshaName(day_number, kvia, leap_year_p, + israel_p); + return holidays; +} + +/* Return a string corresponding to the nth day of the Omer */ +QString Holiday::Sfirah(int day) +{ + /*static char buffer[40]; + char *endings[] = {"th", "st", "nd", "rd"}; + int remainder = day % 10; + // 11-19 and anything not ending with 1, 2, or 3 uses -th as suffix. + if ( ((day >= 11) && (day <= 19)) || (remainder > 3)) remainder = 0; + sprintf(buffer, "%d%s day Omer", day, endings[remainder]); + return buffer; */ + QString buffer; + + buffer.setNum(day); + buffer + i18n(" Omer"); // Fix this to original function + return buffer; + +} diff --git a/korganizer/plugins/hebrew/holiday.h b/korganizer/plugins/hebrew/holiday.h new file mode 100644 index 000000000..6c8c61d9d --- /dev/null +++ b/korganizer/plugins/hebrew/holiday.h @@ -0,0 +1,46 @@ +/*************************************************************************** + * Copyright (C) 2003 by Jonathan Singer * + * jsinger@leeta.net * + * Calendar routines from Hebrew Calendar by Frank Yellin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ +#ifndef HOLIDAY_H +#define HOLIDAY_H + +#include +#include +#include +/** +@author Jonathan Singer +*/ +class Holiday +{ +public: + + Holiday(); + ~Holiday(); + + static QStringList FindHoliday(int month, int day, int weekday, + int kvia, bool leap_year_p, + bool israel_p, int day_number, + int year); + + static QString Sfirah(int); + + static bool CholP; + static bool OmerP; + static bool ParshaP; + +private: + + static QStringList holidays; + static int HolidayFlags; //supposed to be extern + +//parsha Parsha_lookup; +}; + +#endif diff --git a/korganizer/plugins/hebrew/parsha.cpp b/korganizer/plugins/hebrew/parsha.cpp new file mode 100644 index 000000000..21fdf8a4e --- /dev/null +++ b/korganizer/plugins/hebrew/parsha.cpp @@ -0,0 +1,273 @@ +/*************************************************************************** + * Copyright (C) 2003 by Jonathan Singer * + * jsinger@leeta.net * + * Calendar routines from Hebrew Calendar by Frank Yellin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ +#include "parsha.h" +#include + +QStringList Parsha::parshiot_names; + +Parsha::Parsha() +{ + +} + +Parsha::~Parsha() +{ +} + +QString + Parsha::FindParshaName(int daynumber, int kvia, bool leap_p, + bool israel_p) +{ +// The names of the Parshiot. + parshiot_names << + i18n + ("These are weekly readings and do not have translations. They may have different spellings in your language; otherwise, just translate the sound to your characters", + "Bereshit") << i18n("Noach") << i18n("Lech L'cha") << + i18n("Vayera") << i18n("Chaye Sarah") << i18n("Toldot") << + i18n("Vayetze") << i18n("Vayishlach") << i18n("Vayeshev") << + i18n("Miketz") << i18n("Vayigash") << i18n("Vayechi") << + i18n("Shemot") << i18n("Vaera") << i18n("Bo") << i18n("Beshalach") + << i18n("Yitro") << i18n("Mishpatim") << i18n("Terumah") << + i18n("Tetzaveh") << i18n("Ki Tisa") << i18n("Vayakhel") << + i18n("Pekudei") << i18n("Vayikra") << i18n("Tzav") << + i18n("Shemini") << i18n("Tazria") << i18n("Metzora") << + i18n("Acharei Mot") << i18n("Kedoshim") << i18n("Emor") << + i18n("Behar") << i18n("Bechukotai") << i18n("Bemidbar") << + i18n("Naso") << i18n("Behaalotcha") << i18n("Shelach") << + i18n("Korach") << i18n("Chukat") << i18n("Balak") << + i18n("Pinchas") << i18n("Matot") << i18n("Masei") << + i18n("Devarim") << i18n("Vaetchanan") << i18n("Ekev") << + i18n("Reeh") << i18n("Shoftim") << i18n("Ki Tetze") << + i18n("Ki Tavo") << i18n("Nitzavim") << i18n("Vayelech") << + i18n("Haazinu"); + +// Tables for each of the year types. XX indicates that it is a Holiday, and +// a special parsha is read that week. For some year types, Israel is different +// than the diaspora. +// +// The names indicate the day of the week on which Rosh Hashanah fell, whether +// it is a short/normal/long year (kvia=0,1,2), and whether it is a leap year. +// Some year types also have an _Israel version. +// +// Numbers are indices into the table above for a given week. Numbers > 100 indicate +// a double parsha. E.g. 150 means read both table entries 50 and 51. +// +// These tables were stolen (with some massaging) from the GNU code. + +#define XX 255 + static unsigned const char Sat_short[] = + { XX, 52, XX, XX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 121, 23, 24, XX, 25, + 126, 128, 30, 131, 33, 34, 35, 36, 37, 38, 39, 40, 141, 43, 44, + 45, 46, 47, 48, 49, 50, + }; + + static unsigned const char Sat_long[] = + { XX, 52, XX, XX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 121, 23, 24, XX, 25, + 126, 128, 30, 131, 33, 34, 35, 36, 37, 38, 39, 40, 141, 43, 44, + 45, 46, 47, 48, 49, 150, + }; + + static unsigned const char Mon_short[] = + { 51, 52, XX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 121, 23, 24, XX, 25, 126, + 128, 30, 131, 33, 34, 35, 36, 37, 38, 39, 40, 141, 43, 44, 45, + 46, 47, 48, 49, 150, + }; + + static unsigned const char Mon_long[] = /* split */ + { 51, 52, XX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 121, 23, 24, XX, 25, 126, + 128, 30, 131, 33, XX, 34, 35, 36, 37, 138, 40, 141, 43, 44, 45, + 46, 47, 48, 49, 150, + }; + +#define Mon_long_Israel Mon_short + +#define Tue_normal Mon_long +#define Tue_normal_Israel Mon_short + + static unsigned const char Thu_normal[] = + { 52, XX, XX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 121, 23, 24, XX, XX, 25, + 126, 128, 30, 131, 33, 34, 35, 36, 37, 38, 39, 40, 141, 43, 44, + 45, 46, 47, 48, 49, 50, + }; + static unsigned const char Thu_normal_Israel[] = + { 52, XX, XX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 121, 23, 24, XX, 25, 126, + 128, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 141, 43, 44, + 45, 46, 47, 48, 49, 50, + }; + + static unsigned const char Thu_long[] = + { 52, XX, XX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, XX, 25, + 126, 128, 30, 131, 33, 34, 35, 36, 37, 38, 39, 40, 141, 43, 44, + 45, 46, 47, 48, 49, 50, + }; + + static unsigned const char Sat_short_leap[] = + { XX, 52, XX, XX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, XX, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 141, 43, 44, 45, 46, 47, 48, 49, 150, + }; + + static unsigned const char Sat_long_leap[] = + { XX, 52, XX, XX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, XX, 28, 29, 30, 31, 32, 33, XX, 34, 35, 36, 37, 138, + 40, 141, 43, 44, 45, 46, 47, 48, 49, 150, + }; + +#define Sat_long_leap_Israel Sat_short_leap + + static unsigned const char Mon_short_leap[] = + { 51, 52, XX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, XX, 28, 29, 30, 31, 32, 33, XX, 34, 35, 36, 37, 138, 40, + 141, 43, 44, 45, 46, 47, 48, 49, 150, + }; + static unsigned const char Mon_short_leap_Israel[] = + { 51, 52, XX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, XX, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 141, 43, 44, 45, 46, 47, 48, 49, 150, + }; + + static unsigned const char Mon_long_leap[] = + { 51, 52, XX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, XX, XX, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 141, 43, 44, 45, 46, 47, 48, 49, 50, + }; + static unsigned const char Mon_long_leap_Israel[] = + { 51, 52, XX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, XX, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + }; + +#define Tue_normal_leap Mon_long_leap +#define Tue_normal_leap_Israel Mon_long_leap_Israel + + static unsigned const char Thu_short_leap[] = + { 52, XX, XX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, XX, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + }; + + static unsigned const char Thu_long_leap[] = + { 52, XX, XX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, XX, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 150, + }; + +/* Find the parsha for a given day of the year. daynumber is the day of the year. + * kvia and leap_p refer to the year type. + */ + + int week = daynumber / 7; // week of the year + unsigned const char *array = NULL; + int index; + + // get the appropriate array by exhaustive search into the 14 year types. Since we + // know it's a Shabbat, we can find out what day Rosh Hashanah was on by looking + // at daynumber %7. + if (!leap_p) + { + switch (daynumber % 7) + { + case 1: /* RH was on a Saturday */ + if (kvia == 0) + array = Sat_short; + else if (kvia == 2) + array = Sat_long; + break; + case 6: /* RH was on a Monday */ + if (kvia == 0) + array = Mon_short; + else if (kvia == 2) + array = israel_p ? Mon_long_Israel : Mon_long; + break; + case 5: /* RH was on a Tueday */ + if (kvia == 1) + array = israel_p ? Tue_normal_Israel : Tue_normal; + break; + case 3: /* RH was on a Thu */ + if (kvia == 1) + array = israel_p ? Thu_normal_Israel : Thu_normal; + else if (kvia == 2) + array = Thu_long; + break; + } + } + else /* leap year */ + switch (daynumber % 7) + { + case 1: /* RH was on a Sat */ + if (kvia == 0) + array = Sat_short_leap; + else if (kvia == 2) + array = israel_p ? Sat_long_leap_Israel : Sat_long_leap; + break; + case 6: /* RH was on a Mon */ + if (kvia == 0) + array = israel_p ? Mon_short_leap_Israel : Mon_short_leap; + else if (kvia == 2) + array = israel_p ? Mon_long_leap_Israel : Mon_long_leap; + break; + case 5: /* RH was on a Tue */ + if (kvia == 1) + array = + israel_p ? Tue_normal_leap_Israel : Tue_normal_leap; + break; + case 3: /* RH was on a Thu */ + if (kvia == 0) + array = Thu_short_leap; + else if (kvia == 2) + array = Thu_long_leap; + break; + + } + + QString buffer; + + if (array == NULL) + /* Something is terribly wrong. */ + { + buffer = "??Parsha??"; + return buffer; + } + index = array[week]; + if (index == XX) // no Parsha this week. + { + buffer = ""; + return buffer; + } + else if (index < 100) + { + buffer = parshiot_names[index]; + return buffer; + } + else + { // Create a double parsha + buffer = + parshiot_names[index - 100] + "-" + parshiot_names[index - + 99]; + return buffer; + + } +} diff --git a/korganizer/plugins/hebrew/parsha.h b/korganizer/plugins/hebrew/parsha.h new file mode 100644 index 000000000..aac2625ff --- /dev/null +++ b/korganizer/plugins/hebrew/parsha.h @@ -0,0 +1,33 @@ +/*************************************************************************** + * Copyright (C) 2003 by Jonathan Singer * + * jsinger@leeta.net * + * Calendar routines from Hebrew Calendar by Frank Yellin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ +#ifndef PARSHA_H +#define PARSHA_H + +#include +#include + +/** +@author Jonathan Singer +*/ +class Parsha +{ +public: + + Parsha(); + ~Parsha(); + static QString FindParshaName(int daynumber, int kvia, bool leap_p, + bool israel_p); + +private: + static QStringList parshiot_names; +}; + +#endif -- cgit v1.2.1