2
# Gramps - a GTK+/GNOME based genealogy program
4
# Copyright (C) 2001 Donald N. Allingham
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 2 of the License, or
9
# (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
Gregorian calendar module for GRAMPS.
23
The original algorithms for this module came from Scott E. Lee's
24
C implementation. The original C source can be found at Scott's
25
web site at http://www.scottlee.com
28
__author__ = "Donald N. Allingham"
29
__version__ = "$Revision: 1.3 $"
31
#-------------------------------------------------------------------------
35
#-------------------------------------------------------------------------
38
#-------------------------------------------------------------------------
42
#-------------------------------------------------------------------------
44
from gettext import gettext as _
46
#-------------------------------------------------------------------------
50
#-------------------------------------------------------------------------
51
class Islamic(Calendar.Calendar):
52
"""Islamic calendar"""
57
"Muharram", "Safar", "Rabi`al-Awwal", "Rabi`ath-Thani",
58
"Jumada l-Ula", "Jumada t-Tania", "Rajab", "Sha`ban",
59
"Ramadan", "Shawwal", "Dhu l-Qa`da", "Dhu l-Hijja"
63
"muharram" : 1, "safar" : 2, "rabi`al-awwal" : 3,
64
"rabi`ath-thani" : 4, "jumada l-ula" : 5 , "jumada t-tania" : 6,
65
"rajab" : 7, "sha`ban" : 8, "ramadan" : 9,
66
"shawwal" : 10, "dhu l-qa`da" : 11, "dhu l-hijja" : 12
72
def quote_display(self,year,month,day,mode):
73
return "%s (%s)" % (self.display(year,month,day,mode),Islamic.NAME)
75
def set_month_string(self,text):
77
return Islamic.M2NUM[unicode(text.lower())]
83
return Islamic.MONTHS[val-1]
85
return "Illegal Month"
87
def get_sdn(self,year, month, day):
88
v1 = math.ceil(29.5 * (month - 1))
90
v3 = math.floor((3 + (11 *year)) / 30)
92
return int(math.ceil((day + v1 + v2 + v3 + Islamic.EPOCH) - 1))
94
def get_ymd(self,sdn):
95
sdn = math.floor(sdn) + 0.5
96
year = int(math.floor(((30*(sdn-Islamic.EPOCH))+10646)/10631))
97
month = int(min(12, math.ceil((sdn-(29+self.get_sdn(year,1,1)))/29.5) + 1))
98
day = int((sdn - self.get_sdn(year,month,1)) + 1)
99
return (year,month,day)
101
Calendar.register(Islamic)