2005-12-06 12:08:09 +05:30
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2006-02-04 03:33:53 +05:30
|
|
|
# Copyright (C) 2004-2006 Donald N. Allingham
|
2005-12-06 12:08:09 +05:30
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
2007-06-27 10:20:33 +05:30
|
|
|
# This program is distributed in the hope that it will be useful,
|
2005-12-06 12:08:09 +05:30
|
|
|
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
# $Id:_Date_nl.py 9912 2008-01-22 09:17:46Z acraphae $
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
# Written by Benny Malengier
|
2005-12-13 07:37:16 +05:30
|
|
|
# Last change 2005/12/05:
|
|
|
|
# Correspond naming of dates with actual action, so for abbreviation
|
|
|
|
# of month given by mnd. not MAAND
|
|
|
|
# Also less possibilities
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
"""
|
|
|
|
Dutch-specific classes for parsing and displaying dates.
|
|
|
|
"""
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import re
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2007-10-08 22:11:39 +05:30
|
|
|
from gen.lib import Date
|
2006-03-11 10:28:58 +05:30
|
|
|
from _DateParser import DateParser
|
|
|
|
from _DateDisplay import DateDisplay
|
|
|
|
from _DateHandler import register_datehandler
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Dutch parser
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class DateParserNL(DateParser):
|
|
|
|
|
|
|
|
month_to_int = DateParser.month_to_int
|
|
|
|
# Always add dutch and flemish name variants
|
|
|
|
# no matter what the current locale is
|
|
|
|
month_to_int[u"januari"] = 1
|
|
|
|
month_to_int[u"jan"] = 1
|
|
|
|
# Add other common latin, local and historical variants
|
|
|
|
month_to_int[u"januaris"] = 1
|
|
|
|
month_to_int[u"feber"] = 2
|
|
|
|
month_to_int[u"februaris"] = 2
|
2006-03-01 01:24:35 +05:30
|
|
|
month_to_int[u"merz"] = 3
|
2005-12-06 12:08:09 +05:30
|
|
|
month_to_int[u"aprilis"] = 4
|
|
|
|
month_to_int[u"maius"] = 5
|
|
|
|
month_to_int[u"junius"] = 6
|
|
|
|
month_to_int[u"julius"] = 7
|
|
|
|
month_to_int[u"augst"] = 8
|
|
|
|
month_to_int[u"7ber"] = 9
|
|
|
|
month_to_int[u"7bris"] = 9
|
|
|
|
month_to_int[u"8ber"] = 10
|
|
|
|
month_to_int[u"8bris"] = 10
|
|
|
|
month_to_int[u"9ber"] = 11
|
|
|
|
month_to_int[u"9bris"] = 11
|
|
|
|
month_to_int[u"10ber"] = 12
|
|
|
|
month_to_int[u"10bris"] = 12
|
|
|
|
month_to_int[u"xber"] = 12
|
|
|
|
month_to_int[u"xbris"] = 12
|
|
|
|
|
|
|
|
modifier_to_int = {
|
|
|
|
u'voor' : Date.MOD_BEFORE,
|
2007-06-27 10:20:33 +05:30
|
|
|
u'na' : Date.MOD_AFTER,
|
|
|
|
u'tegen' : Date.MOD_ABOUT,
|
|
|
|
u'om' : Date.MOD_ABOUT,
|
|
|
|
u'rond' : Date.MOD_ABOUT,
|
|
|
|
u'circa' : Date.MOD_ABOUT,
|
|
|
|
u'ca.' : Date.MOD_ABOUT,
|
2005-12-06 12:08:09 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
calendar_to_int = {
|
2007-06-27 10:20:33 +05:30
|
|
|
u'gregoriaans' : Date.CAL_GREGORIAN,
|
|
|
|
u'greg.' : Date.CAL_GREGORIAN,
|
|
|
|
u'juliaans' : Date.CAL_JULIAN,
|
|
|
|
u'jul.' : Date.CAL_JULIAN,
|
|
|
|
u'hebreeuws' : Date.CAL_HEBREW,
|
|
|
|
u'hebr.' : Date.CAL_HEBREW,
|
|
|
|
u'islamitisch' : Date.CAL_ISLAMIC,
|
|
|
|
u'isl.' : Date.CAL_ISLAMIC,
|
|
|
|
u'franse republiek': Date.CAL_FRENCH,
|
|
|
|
u'fran.' : Date.CAL_FRENCH,
|
|
|
|
u'persisch' : Date.CAL_PERSIAN,
|
2005-12-06 12:08:09 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
quality_to_int = {
|
2007-06-27 10:20:33 +05:30
|
|
|
u'geschat' : Date.QUAL_ESTIMATED,
|
|
|
|
u'gesch.' : Date.QUAL_ESTIMATED,
|
|
|
|
u'berekend' : Date.QUAL_CALCULATED,
|
|
|
|
u'ber.' : Date.QUAL_CALCULATED,
|
2005-12-06 12:08:09 +05:30
|
|
|
}
|
|
|
|
|
2007-06-27 10:20:33 +05:30
|
|
|
bce = ["voor onze tijdrekening", "voor Christus", "v. Chr."] + DateParser.bce
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
def init_strings(self):
|
|
|
|
DateParser.init_strings(self)
|
2007-06-27 10:20:33 +05:30
|
|
|
self._span = re.compile("(van)\s+(?P<start>.+)\s+(tot)\s+(?P<stop>.+)",
|
2005-12-06 12:08:09 +05:30
|
|
|
re.IGNORECASE)
|
2007-06-27 10:20:33 +05:30
|
|
|
self._range = re.compile("tussen\s+(?P<start>.+)\s+en\s+(?P<stop>.+)",
|
|
|
|
re.IGNORECASE)
|
|
|
|
self._text2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?'
|
|
|
|
% self._mon_str,
|
|
|
|
re.IGNORECASE)
|
|
|
|
self._jtext2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?'
|
|
|
|
% self._jmon_str,
|
|
|
|
re.IGNORECASE)
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Dutch display
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class DateDisplayNL(DateDisplay):
|
|
|
|
|
|
|
|
calendar = (
|
2006-05-02 02:41:26 +05:30
|
|
|
"", u" (juliaans)", u" (hebreeuws)",
|
|
|
|
u" (franse republiek)", u" (persisch)", u" (islamitisch)"
|
2005-12-06 12:08:09 +05:30
|
|
|
)
|
|
|
|
|
2007-06-27 10:20:33 +05:30
|
|
|
_mod_str = ("", u"voor ", u"na ", u"rond ", "", "", "")
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2007-06-27 10:20:33 +05:30
|
|
|
_qual_str = ("", u"geschat ", u"berekend ")
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
_bce_str = "%s v. Chr."
|
|
|
|
|
|
|
|
formats = (
|
2007-06-27 10:20:33 +05:30
|
|
|
"JJJJ-MM-DD (ISO)", "Numerisch DD/MM/JJ", "Maand Dag, Jaar",
|
2005-12-13 07:37:16 +05:30
|
|
|
"Mnd. Dag Jaar", "Dag Maand Jaar", "Dag Mnd. Jaar"
|
2005-12-06 12:08:09 +05:30
|
|
|
)
|
|
|
|
|
2007-06-27 10:20:33 +05:30
|
|
|
def _display_gregorian(self, date_val):
|
|
|
|
year = self._slash_year(date_val[2], date_val[3])
|
2005-12-06 12:08:09 +05:30
|
|
|
if self.format == 0:
|
2005-12-13 07:37:16 +05:30
|
|
|
return self.display_iso(date_val)
|
2005-12-06 12:08:09 +05:30
|
|
|
elif self.format == 1:
|
2006-05-02 02:41:26 +05:30
|
|
|
if date_val[3]:
|
|
|
|
return self.display_iso(date_val)
|
2005-12-06 12:08:09 +05:30
|
|
|
else:
|
2006-05-02 02:41:26 +05:30
|
|
|
# Numeric
|
|
|
|
if date_val[0] == 0 and date_val[1] == 0:
|
|
|
|
value = str(date_val[2])
|
|
|
|
else:
|
2007-06-27 10:20:33 +05:30
|
|
|
value = self._tformat.replace('%m', str(date_val[1]))
|
|
|
|
value = value.replace('%d', str(date_val[0]))
|
|
|
|
value = value.replace('%Y', str(abs(date_val[2])))
|
|
|
|
value = value.replace('-', '/')
|
2005-12-06 12:08:09 +05:30
|
|
|
elif self.format == 2:
|
|
|
|
# Month Day, Year
|
|
|
|
if date_val[0] == 0:
|
|
|
|
if date_val[1] == 0:
|
|
|
|
value = year
|
|
|
|
else:
|
2007-06-27 10:20:33 +05:30
|
|
|
value = "%s %s" % (self._months[date_val[1]], year)
|
2005-12-06 12:08:09 +05:30
|
|
|
else:
|
2007-06-27 10:20:33 +05:30
|
|
|
value = "%s %d, %s" % (self._months[date_val[1]], date_val[0], year)
|
2005-12-06 12:08:09 +05:30
|
|
|
elif self.format == 3:
|
2005-12-13 07:37:16 +05:30
|
|
|
# Mnd Day, Year
|
2005-12-06 12:08:09 +05:30
|
|
|
if date_val[0] == 0:
|
|
|
|
if date_val[1] == 0:
|
|
|
|
value = year
|
|
|
|
else:
|
2007-06-27 10:20:33 +05:30
|
|
|
value = "%s %s" % (self.MONS[date_val[1]], year)
|
2005-12-06 12:08:09 +05:30
|
|
|
else:
|
2007-06-27 10:20:33 +05:30
|
|
|
value = "%s %d, %s" % (self.MONS[date_val[1]], date_val[0], year)
|
2005-12-06 12:08:09 +05:30
|
|
|
elif self.format == 4:
|
2005-12-13 07:37:16 +05:30
|
|
|
# Day Month Year
|
2005-12-06 12:08:09 +05:30
|
|
|
if date_val[0] == 0:
|
|
|
|
if date_val[1] == 0:
|
|
|
|
value = year
|
|
|
|
else:
|
2007-06-27 10:20:33 +05:30
|
|
|
value = "%s %s" % (self._months[date_val[1]], year)
|
2005-12-06 12:08:09 +05:30
|
|
|
else:
|
2007-06-27 10:20:33 +05:30
|
|
|
value = "%d %s %s" % (date_val[0], self._months[date_val[1]], year)
|
2005-12-06 12:08:09 +05:30
|
|
|
else:
|
2005-12-13 07:37:16 +05:30
|
|
|
# Day Mnd Year
|
2005-12-06 12:08:09 +05:30
|
|
|
if date_val[0] == 0:
|
|
|
|
if date_val[1] == 0:
|
|
|
|
value = year
|
|
|
|
else:
|
2007-06-27 10:20:33 +05:30
|
|
|
value = "%s %s" % (self.MONS[date_val[1]], year)
|
2005-12-06 12:08:09 +05:30
|
|
|
else:
|
2007-06-27 10:20:33 +05:30
|
|
|
value = "%d %s %s" % (date_val[0], self.MONS[date_val[1]], year)
|
2005-12-13 07:37:16 +05:30
|
|
|
if date_val[2] < 0:
|
|
|
|
return self._bce_str % value
|
|
|
|
else:
|
|
|
|
return value
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2007-06-27 10:20:33 +05:30
|
|
|
def display(self, date):
|
2005-12-06 12:08:09 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Return a text string representing the date.
|
2005-12-06 12:08:09 +05:30
|
|
|
"""
|
|
|
|
mod = date.get_modifier()
|
|
|
|
cal = date.get_calendar()
|
|
|
|
qual = date.get_quality()
|
|
|
|
start = date.get_start_date()
|
|
|
|
|
|
|
|
qual_str = self._qual_str[qual]
|
|
|
|
|
|
|
|
if mod == Date.MOD_TEXTONLY:
|
|
|
|
return date.get_text()
|
|
|
|
elif start == Date.EMPTY:
|
|
|
|
return ""
|
|
|
|
elif mod == Date.MOD_SPAN:
|
|
|
|
d1 = self.display_cal[cal](start)
|
|
|
|
d2 = self.display_cal[cal](date.get_stop_date())
|
2007-06-27 10:20:33 +05:30
|
|
|
return "%s%s %s %s %s%s" % (qual_str, u'van', d1,
|
|
|
|
u'tot', d2, self.calendar[cal])
|
2005-12-06 12:08:09 +05:30
|
|
|
elif mod == Date.MOD_RANGE:
|
|
|
|
d1 = self.display_cal[cal](start)
|
|
|
|
d2 = self.display_cal[cal](date.get_stop_date())
|
2007-06-27 10:20:33 +05:30
|
|
|
return "%stussen %s en %s%s" % (qual_str, d1, d2,
|
|
|
|
self.calendar[cal])
|
2005-12-06 12:08:09 +05:30
|
|
|
else:
|
|
|
|
text = self.display_cal[date.get_calendar()](start)
|
2007-06-27 10:20:33 +05:30
|
|
|
return "%s%s%s%s" % (qual_str, self._mod_str[mod], text,
|
|
|
|
self.calendar[cal])
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Register classes
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2007-06-27 10:20:33 +05:30
|
|
|
register_datehandler(('nl_NL', 'dutch', 'nl_BE', 'nl'),
|
2005-12-06 12:08:09 +05:30
|
|
|
DateParserNL, DateDisplayNL)
|