2006-05-02 02:41:26 +05:30
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
|
|
|
# Copyright (C) 2004-2006 Donald N. Allingham
|
|
|
|
#
|
|
|
|
# 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,
|
2006-05-02 02:41:26 +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
|
|
|
|
#
|
|
|
|
|
2007-06-27 10:20:33 +05:30
|
|
|
# $Id: Date_sk.py, v 1.1.2.4 2006/04/16 03:20:06 rshura Exp $
|
2006-05-02 02:41:26 +05:30
|
|
|
|
|
|
|
"""
|
|
|
|
Slovak-specific classes for parsing and displaying dates.
|
|
|
|
"""
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import re
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-05-15 01:44:59 +05:30
|
|
|
from RelLib import Date
|
|
|
|
from _DateParser import DateParser
|
|
|
|
from _DateDisplay import DateDisplay
|
|
|
|
from _DateHandler import register_datehandler
|
2006-05-02 02:41:26 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Slovak parser
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class DateParserSK(DateParser):
|
|
|
|
|
|
|
|
modifier_to_int = {
|
2007-06-27 10:20:33 +05:30
|
|
|
u'pred' : Date.MOD_BEFORE,
|
|
|
|
u'do' : Date.MOD_BEFORE,
|
|
|
|
u'po' : Date.MOD_AFTER,
|
|
|
|
u'asi' : Date.MOD_ABOUT,
|
|
|
|
u'okolo' : Date.MOD_ABOUT,
|
|
|
|
u'pribl.' : Date.MOD_ABOUT,
|
2006-05-02 02:41:26 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
calendar_to_int = {
|
2007-06-27 10:20:33 +05:30
|
|
|
u'gregoriánsky' : Date.CAL_GREGORIAN,
|
|
|
|
u'g' : Date.CAL_GREGORIAN,
|
|
|
|
u'juliánský' : Date.CAL_JULIAN,
|
|
|
|
u'j' : Date.CAL_JULIAN,
|
|
|
|
u'hebrejský' : Date.CAL_HEBREW,
|
|
|
|
u'h' : Date.CAL_HEBREW,
|
|
|
|
u'islamský' : Date.CAL_ISLAMIC,
|
|
|
|
u'i' : Date.CAL_ISLAMIC,
|
|
|
|
u'republikánsky' : Date.CAL_FRENCH,
|
|
|
|
u'r' : Date.CAL_FRENCH,
|
|
|
|
u'perzský' : Date.CAL_PERSIAN,
|
|
|
|
u'p' : Date.CAL_PERSIAN,
|
2006-05-02 02:41:26 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
quality_to_int = {
|
2007-06-27 10:20:33 +05:30
|
|
|
u'odhadovaný' : Date.QUAL_ESTIMATED,
|
|
|
|
u'odh.' : Date.QUAL_ESTIMATED,
|
|
|
|
u'vypočítaný' : Date.QUAL_CALCULATED,
|
|
|
|
u'vyp.' : Date.QUAL_CALCULATED,
|
2006-05-02 02:41:26 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
def init_strings(self):
|
|
|
|
DateParser.init_strings(self)
|
|
|
|
_span_1 = [u'od']
|
|
|
|
_span_2 = [u'do']
|
|
|
|
_range_1 = [u'medzi']
|
|
|
|
_range_2 = [u'a']
|
2007-06-27 10:20:33 +05:30
|
|
|
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
|
|
|
|
('|'.join(_span_1), '|'.join(_span_2)),
|
|
|
|
re.IGNORECASE)
|
|
|
|
self._range = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
|
|
|
|
('|'.join(_range_1), '|'.join(_range_2)),
|
|
|
|
re.IGNORECASE)
|
2006-05-02 02:41:26 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Slovak display
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class DateDisplaySK(DateDisplay):
|
|
|
|
|
|
|
|
calendar = (
|
|
|
|
"", u" (juliánský)", u" (hebrejský)",
|
|
|
|
u" (republikánsky)", u" (perzský)", u" (islamský)"
|
|
|
|
)
|
|
|
|
|
2007-06-27 10:20:33 +05:30
|
|
|
_mod_str = ("", u"pred ", u"po ", u"okolo ", "", "", "")
|
2006-05-02 02:41:26 +05:30
|
|
|
|
2007-06-27 10:20:33 +05:30
|
|
|
_qual_str = ("", "odh. ", "vyp. ")
|
2006-05-02 02:41:26 +05:30
|
|
|
|
|
|
|
formats = (
|
2007-06-27 10:20:33 +05:30
|
|
|
"RRRR-MM-DD (ISO)", "numerický", "Mesiac Deň, Rok",
|
2006-05-02 02:41:26 +05:30
|
|
|
"MES Deň, Rok", "Deň, Mesiac, Rok", "Deň MES Rok"
|
|
|
|
)
|
|
|
|
|
2007-06-27 10:20:33 +05:30
|
|
|
def display(self, date):
|
2006-05-02 02:41:26 +05:30
|
|
|
"""
|
|
|
|
Returns a text string representing the date.
|
|
|
|
"""
|
|
|
|
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'od', d1,
|
|
|
|
u'do', d2, self.calendar[cal])
|
2006-05-02 02:41:26 +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 "%s%s %s %s %s%s" % (qual_str, u'medzi',
|
|
|
|
d1, u'a', d2, self.calendar[cal])
|
2006-05-02 02:41:26 +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])
|
2006-05-02 02:41:26 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Register classes
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2007-06-27 10:20:33 +05:30
|
|
|
register_datehandler(('sk_SK', 'sk', 'SK'), DateParserSK, DateDisplaySK)
|