Swedish calendar added.
svn: r11665
This commit is contained in:
@@ -539,3 +539,31 @@ def islamic_ymd(sdn):
|
||||
month = int(min(12, math.ceil((sdn-(29+islamic_sdn(year, 1, 1)))/29.5) + 1))
|
||||
day = int((sdn - islamic_sdn(year, month, 1)) + 1)
|
||||
return (year, month, day)
|
||||
|
||||
def swedish_sdn(year, month, day):
|
||||
"""Convert a Swedish (almost Julian) date to an SDN number."""
|
||||
return julian_sdn(year, month, day)-1
|
||||
|
||||
def swedish_ymd(sdn):
|
||||
"""Convert an SDN number to a Swedish (almost Julian) calendar date."""
|
||||
if sdn == 2346425:
|
||||
return (1712,2,30)
|
||||
return julian_ymd(sdn+1)
|
||||
"""
|
||||
print "1700-02-28J=", julian_sdn(1700,2,28)
|
||||
print "1700-02-29S=", swedish_sdn(1700,2,29)
|
||||
print "1700-03-01S=", swedish_sdn(1700,3,1)
|
||||
print
|
||||
print "1712-02-29S=", swedish_sdn(1712,2,29)
|
||||
print "1712-02-30S=", swedish_sdn(1712,2,30)
|
||||
print "1712-03-01J=", julian_sdn(1712,3,1)
|
||||
print
|
||||
print "1753-02-17J=", julian_sdn(1753,2,17)
|
||||
print "1753-03-01G=", gregorian_sdn(1753,3,1)
|
||||
print
|
||||
print "2346424S=", swedish_ymd(2346424)
|
||||
print "2346425S=", swedish_ymd(2346425)
|
||||
print "2346426J=", julian_ymd(2346426)
|
||||
print
|
||||
quit()
|
||||
"""
|
@@ -1,4 +1,4 @@
|
||||
#
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
@@ -53,8 +53,10 @@ log = logging.getLogger(".Date")
|
||||
#------------------------------------------------------------------------
|
||||
from gen.lib.calendar import (gregorian_sdn, julian_sdn, hebrew_sdn,
|
||||
french_sdn, persian_sdn, islamic_sdn,
|
||||
swedish_sdn,
|
||||
gregorian_ymd, julian_ymd, hebrew_ymd,
|
||||
french_ymd, persian_ymd, islamic_ymd)
|
||||
french_ymd, persian_ymd, islamic_ymd,
|
||||
swedish_ymd)
|
||||
import Config
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@@ -601,6 +603,7 @@ class Date:
|
||||
CAL_FRENCH = 3
|
||||
CAL_PERSIAN = 4
|
||||
CAL_ISLAMIC = 5
|
||||
CAL_SWEDISH = 6
|
||||
|
||||
NEWYEAR_JAN1 = 0 # CODE
|
||||
NEWYEAR_MAR1 = 1
|
||||
@@ -625,6 +628,7 @@ class Date:
|
||||
french_sdn,
|
||||
persian_sdn,
|
||||
islamic_sdn,
|
||||
swedish_sdn,
|
||||
]
|
||||
|
||||
_calendar_change = [
|
||||
@@ -634,6 +638,7 @@ class Date:
|
||||
french_ymd,
|
||||
persian_ymd,
|
||||
islamic_ymd,
|
||||
swedish_ymd,
|
||||
]
|
||||
|
||||
calendar_names = ["Gregorian",
|
||||
@@ -641,7 +646,8 @@ class Date:
|
||||
"Hebrew",
|
||||
"French Republican",
|
||||
"Persian",
|
||||
"Islamic"]
|
||||
"Islamic",
|
||||
"Swedish"]
|
||||
|
||||
|
||||
ui_calendar_names = [_("Gregorian"),
|
||||
@@ -649,7 +655,8 @@ class Date:
|
||||
_("Hebrew"),
|
||||
_("French Republican"),
|
||||
_("Persian"),
|
||||
_("Islamic")]
|
||||
_("Islamic"),
|
||||
_("Swedish")]
|
||||
|
||||
def __init__(self, *source, **kwargs):
|
||||
"""
|
||||
@@ -1099,6 +1106,7 @@ class Date:
|
||||
CAL_FRENCH - French Republican calendar
|
||||
CAL_PERSIAN - Persian calendar
|
||||
CAL_ISLAMIC - Islamic calendar
|
||||
CAL_SWEDISH - Swedish calendar 1700-03-01 -> 1712-02-30!
|
||||
"""
|
||||
return self.calendar
|
||||
|
||||
@@ -1107,7 +1115,7 @@ class Date:
|
||||
Set the calendar selected for the date.
|
||||
"""
|
||||
if val not in (Date.CAL_GREGORIAN, Date.CAL_JULIAN, Date.CAL_HEBREW,
|
||||
Date.CAL_FRENCH, Date.CAL_PERSIAN, Date.CAL_ISLAMIC):
|
||||
Date.CAL_FRENCH, Date.CAL_PERSIAN, Date.CAL_ISLAMIC, Date-CAL_SWEDISH):
|
||||
raise DateError("Invalid calendar")
|
||||
self.calendar = val
|
||||
|
||||
@@ -1399,7 +1407,8 @@ class Date:
|
||||
raise DateError("Invalid quality")
|
||||
if calendar not in (Date.CAL_GREGORIAN, Date.CAL_JULIAN,
|
||||
Date.CAL_HEBREW, Date.CAL_FRENCH,
|
||||
Date.CAL_PERSIAN, Date.CAL_ISLAMIC):
|
||||
Date.CAL_PERSIAN, Date.CAL_ISLAMIC,
|
||||
Date.CAL_SWEDISH):
|
||||
raise DateError("Invalid calendar")
|
||||
|
||||
self.quality = quality
|
||||
|
Reference in New Issue
Block a user