gramps/src/DateHandler/_DateUtils.py
Raphael Ackermann bbe2cc6d4e 2008-01-22 Raphael Ackermann <raphael.ackermann@gmail.com>
* src/* Everything but src/images/* and src/data/* add correct svn 
	properties with the commands:
	svn propset -R svn:mime-type text/plain src/
	svn propset -R svn:eol-style native src/
	svn propset -R svn:keywords Id src/
	See below why the Id keyword is enough. From svn help propset
	svn:keywords   - Keywords to be expanded.  Valid keywords are:
      URL, HeadURL             - The URL for the head version of the object.
      Author, LastChangedBy    - The last person to modify the file.
      Date, LastChangedDate    - The date/time the object was last modified.
      Rev, Revision,           - The last revision the object changed.
      LastChangedRevision
      Id                       - A compressed summary of the previous
                                   4 keywords.

svn: r9912
2008-01-22 09:17:46 +00:00

90 lines
2.8 KiB
Python

#
# 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.
#
# This program is distributed in the hope that it will be useful,
# 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
#
# $Id$
"""
Class handling language-specific selection for date parser and displayer.
"""
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from DateHandler import LANG_TO_DISPLAY, LANG, parser, displayer
#--------------------------------------------------------------
#
# Convenience functions
#
#--------------------------------------------------------------
def get_date_formats():
"""
Returns the lists supported formats for date parsers and displayers
"""
try:
return LANG_TO_DISPLAY[LANG].formats
except:
return LANG_TO_DISPLAY["C"].formats
def set_format(value):
try:
displayer.set_format(value)
except:
pass
def set_date(date_base, text) :
"""
Sets the date of the DateBase instance.
The date is parsed into a Date instance.
@param date_base: The DateBase instance to set the date to.
@type date_base: DateBase
@param text: The text to use for the text string in date
@type text: str
"""
parser.set_date(date_base.get_date_object(),text)
def get_date(date_base) :
"""
Returns a string representation of the date of the DateBase instance.
This representation is based off the default date display format
determined by the locale's DateDisplay instance.
@return: Returns a string representing the DateBase date
@rtype: str
"""
return displayer.display(date_base.get_date_object())
def get_quote_date(date_base):
"""
Returns a string representation of the date of the DateBase instance.
This representation is based off the default date display format
determined by the locale's DateDisplay instance. The date is
enclosed in quotes if the Date is not a valid date.
@return: Returns a string representing the DateBase date
@rtype: str
"""
return displayer.quote_display(date_base.get_date_object())