3993: Add Jewish holidays and translate holidays and countries names (part 1), by igal_shapira
svn: r15438
This commit is contained in:
parent
2a0ae02088
commit
3af2af9dd2
@ -1,7 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<calendar>
|
<calendar>
|
||||||
<country name="">
|
|
||||||
</country>
|
|
||||||
<country name="United States">
|
<country name="United States">
|
||||||
<date name="New Year's Eve" value="*/12/31" type="national" />
|
<date name="New Year's Eve" value="*/12/31" type="national" />
|
||||||
<date name="New Year's Day" value="*/1/1" type="national" />
|
<date name="New Year's Day" value="*/1/1" type="national" />
|
||||||
@ -521,4 +519,34 @@
|
|||||||
<date name="Възнесение господне" value="2011/6/2" type="religious" />
|
<date name="Възнесение господне" value="2011/6/2" type="religious" />
|
||||||
<date name="Възнесение господне" value="2012/5/24" type="religious" />
|
<date name="Възнесение господне" value="2012/5/24" type="religious" />
|
||||||
</country>
|
</country>
|
||||||
|
<country name="Jewish Holidays">
|
||||||
|
<date name="Purim" value="> passover(y)" offset="-30"/>
|
||||||
|
<date name="Passover" value="> passover(y)" offset="0"/>
|
||||||
|
<date name="2 of Passover" value="> passover(y)" offset="1"/>
|
||||||
|
<date name="3 of Passover" value="> passover(y)" offset="2"/>
|
||||||
|
<date name="4 of Passover" value="> passover(y)" offset="3"/>
|
||||||
|
<date name="5 of Passover" value="> passover(y)" offset="4"/>
|
||||||
|
<date name="6 of Passover" value="> passover(y)" offset="5"/>
|
||||||
|
<date name="7 of Passover" value="> passover(y)" offset="6"/>
|
||||||
|
<date name="Shavuot" value="> passover(y)" offset="50"/>
|
||||||
|
<date name="Rosh Ha'Shana" value="> passover(y)" offset="163"/>
|
||||||
|
<date name="Rosh Ha'Shana 2" value="> passover(y)" offset="164"/>
|
||||||
|
<date name="Yom Kippur" value="> passover(y)" offset="172"/>
|
||||||
|
<date name="Sukot" value="> passover(y)" offset="177"/>
|
||||||
|
<date name="2 of Sukot" value="> passover(y)" offset="178"/>
|
||||||
|
<date name="3 of Sukot" value="> passover(y)" offset="179"/>
|
||||||
|
<date name="4 of Sukot" value="> passover(y)" offset="180"/>
|
||||||
|
<date name="5 of Sukot" value="> passover(y)" offset="181"/>
|
||||||
|
<date name="6 of Sukot" value="> passover(y)" offset="182"/>
|
||||||
|
<date name="7 of Sukot" value="> passover(y)" offset="183"/>
|
||||||
|
<date name="Simhat Tora" value="> passover(y)" offset="184"/>
|
||||||
|
<date name="Hanuka" value="> hanuka(y)" offset="0"/>
|
||||||
|
<date name="2 of Hanuka" value="> hanuka(y)" offset="1"/>
|
||||||
|
<date name="3 of Hanuka" value="> hanuka(y)" offset="2"/>
|
||||||
|
<date name="4 of Hanuka" value="> hanuka(y)" offset="3"/>
|
||||||
|
<date name="5 of Hanuka" value="> hanuka(y)" offset="4"/>
|
||||||
|
<date name="6 of Hanuka" value="> hanuka(y)" offset="5"/>
|
||||||
|
<date name="7 of Hanuka" value="> hanuka(y)" offset="6"/>
|
||||||
|
<date name="8 of Hanuka" value="> hanuka(y)" offset="7"/>
|
||||||
|
</country>
|
||||||
</calendar>
|
</calendar>
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
from gen.ggettext import gettext as _
|
from gen.ggettext import gettext as _
|
||||||
from xml.parsers import expat
|
from xml.parsers import expat
|
||||||
|
from gen.lib.calendar import (gregorian_ymd, hebrew_sdn)
|
||||||
import datetime
|
import datetime
|
||||||
import math
|
import math
|
||||||
import const
|
import const
|
||||||
@ -70,6 +71,26 @@ def easter(year):
|
|||||||
day = l + 28 - 31 * (month / 4)
|
day = l + 28 - 31 * (month / 4)
|
||||||
return "%d/%d/%d" % (year, month, day)
|
return "%d/%d/%d" % (year, month, day)
|
||||||
|
|
||||||
|
def passover(year):
|
||||||
|
"""
|
||||||
|
Returns the date of Passover in a given Gregorian year.
|
||||||
|
"""
|
||||||
|
heb_year = year + 3760
|
||||||
|
heb = hebrew_sdn(heb_year, 8, 15) #Passover, 15 Nissan
|
||||||
|
|
||||||
|
return "%d/%d/%d" % gregorian_ymd(heb)
|
||||||
|
|
||||||
|
def hanuka(year):
|
||||||
|
"""
|
||||||
|
Returns the date of first day of Hanuka in a given Gregorian year.
|
||||||
|
We can't use passover as an offset, because the year length changes.
|
||||||
|
The hebrew year have 6 possible lengths.
|
||||||
|
"""
|
||||||
|
heb_year = year + 3761 #Not 3760, because Hanuka is in Nov/Dec of the previous year
|
||||||
|
heb = hebrew_sdn(heb_year, 3, 25) #Hanuka, 25 Kislev
|
||||||
|
|
||||||
|
return "%d/%d/%d" % gregorian_ymd(heb)
|
||||||
|
|
||||||
def dst(year, area="us"):
|
def dst(year, area="us"):
|
||||||
"""
|
"""
|
||||||
Return Daylight Saving Time start/stop in a given area ("us", "eu").
|
Return Daylight Saving Time start/stop in a given area ("us", "eu").
|
||||||
@ -149,7 +170,7 @@ class HolidayTable(object):
|
|||||||
if country_element.get_name() == "country":
|
if country_element.get_name() == "country":
|
||||||
country_name = country_element.get_attribute("name")
|
country_name = country_element.get_attribute("name")
|
||||||
if country_name not in HolidayTable.__countries:
|
if country_name not in HolidayTable.__countries:
|
||||||
HolidayTable.__countries.append(country_name)
|
HolidayTable.__countries.append(_(country_name))
|
||||||
|
|
||||||
def __init_table(self):
|
def __init_table(self):
|
||||||
""" Initialize the holiday table structure. """
|
""" Initialize the holiday table structure. """
|
||||||
@ -188,7 +209,7 @@ class HolidayTable(object):
|
|||||||
while date.year == year:
|
while date.year == year:
|
||||||
holidays = calendar.check_date(date)
|
holidays = calendar.check_date(date)
|
||||||
for text in holidays:
|
for text in holidays:
|
||||||
self.__holidays[date.month][date.day].append(text)
|
self.__holidays[date.month][date.day].append(_(text))
|
||||||
date = date.fromordinal(date.toordinal() + 1)
|
date = date.fromordinal(date.toordinal() + 1)
|
||||||
|
|
||||||
def get_holidays(self, month, day):
|
def get_holidays(self, month, day):
|
||||||
@ -308,7 +329,7 @@ class _Holidays:
|
|||||||
""" Parse the holiday date XML items """
|
""" Parse the holiday date XML items """
|
||||||
for country_set in self.elements.get_children():
|
for country_set in self.elements.get_children():
|
||||||
if country_set.get_name() == "country" and \
|
if country_set.get_name() == "country" and \
|
||||||
country_set.get_attribute("name") == self.country:
|
_(country_set.get_attribute("name")) == self.country:
|
||||||
for date in country_set.get_children():
|
for date in country_set.get_children():
|
||||||
if date.get_name() == "date":
|
if date.get_name() == "date":
|
||||||
data = {"value" : "",
|
data = {"value" : "",
|
||||||
|
Loading…
Reference in New Issue
Block a user