* src/DateDisplay.py: Now proper capitalization for _MONS.

* src/DateParser.py: Support for the RFC-2822 dates (email standard).
* NEWS: Update.

* src/DateDisplay.py: don't rely on strftime, since it does not


svn: r3577
This commit is contained in:
Alex Roitman 2004-09-27 04:20:43 +00:00
parent 37314056ca
commit be471c8276
4 changed files with 74 additions and 18 deletions

View File

@ -1,5 +1,10 @@
2004-09-26 Alex Roitman <shura@alex.neuro.umn.edu>
* src/DateDisplay.py: Now proper capitalization for _MONS.
* src/DateParser.py: Support for the RFC-2822 dates (email standard).
* NEWS: Update.
2004-09-26 Don Allingham <dallingham@users.sourceforge.net>
* src/DateDisplay: don't rely on strftime, since it does not
* src/DateDisplay.py: don't rely on strftime, since it does not
handle dates before 1900
2004-09-25 Don Allingham <dallingham@users.sourceforge.net>

15
NEWS
View File

@ -1,4 +1,17 @@
Version 1.1.1 -- the "Rat cake, rat sorbet, rat pudding, or strawberry tart" release
* GeneWeb Import/Export filters (Martin Hawlisch), GeneWeb mime type.
* Rework of the Date support. Separate classes for parsing and display,
allowing easy localization not limited to English sentences. Utilization
of locale info for numerical date parsing and display. New DateEditor
dialog for building precise date when parsing fails.
* Lots of stuff ported over from STABLE, see NEWS in stable version for details.
* Installation improvements
* Removal of PIL dependency.
* Numerous interface improvements.
* In-memory editing for GRAMPS XML and GEDCOM data.
* Proper support for same sex relationships.
* Proper use of GConf: schemas with the description strings, partitioning of
the preferences into subdirectories, error checking, change notifications.
* New "Save as" wizard interface: replaces old Export and Save as options.
Note: this is still unfinished at the 1.1.1 release time, please be patient.
* New Find interface for People View.
@ -12,7 +25,7 @@ Version 1.1.1 -- the "Rat cake, rat sorbet, rat pudding, or strawberry tart" rel
Spouses, Siblings, Children, and Parents.
* Command line arguments handling is back on track.
* Sorting improvements.
* Numerous bug fixes.
* Huge number of bug fixes.
Version 1.1.0 -- the "And now for something completely different" release
* Berkeley database backend!!! Many thanks to Billy Earney for db expertise!

View File

@ -76,18 +76,18 @@ class DateDisplay:
_MONS = (
"",
unicode(locale.nl_langinfo(locale.ABMON_1),_codeset).upper(),
unicode(locale.nl_langinfo(locale.ABMON_2),_codeset).upper(),
unicode(locale.nl_langinfo(locale.ABMON_3),_codeset).upper(),
unicode(locale.nl_langinfo(locale.ABMON_4),_codeset).upper(),
unicode(locale.nl_langinfo(locale.ABMON_5),_codeset).upper(),
unicode(locale.nl_langinfo(locale.ABMON_6),_codeset).upper(),
unicode(locale.nl_langinfo(locale.ABMON_7),_codeset).upper(),
unicode(locale.nl_langinfo(locale.ABMON_8),_codeset).upper(),
unicode(locale.nl_langinfo(locale.ABMON_9),_codeset).upper(),
unicode(locale.nl_langinfo(locale.ABMON_10),_codeset).upper(),
unicode(locale.nl_langinfo(locale.ABMON_11),_codeset).upper(),
unicode(locale.nl_langinfo(locale.ABMON_12),_codeset).upper(),
unicode(locale.nl_langinfo(locale.ABMON_1),_codeset),
unicode(locale.nl_langinfo(locale.ABMON_2),_codeset),
unicode(locale.nl_langinfo(locale.ABMON_3),_codeset),
unicode(locale.nl_langinfo(locale.ABMON_4),_codeset),
unicode(locale.nl_langinfo(locale.ABMON_5),_codeset),
unicode(locale.nl_langinfo(locale.ABMON_6),_codeset),
unicode(locale.nl_langinfo(locale.ABMON_7),_codeset),
unicode(locale.nl_langinfo(locale.ABMON_8),_codeset),
unicode(locale.nl_langinfo(locale.ABMON_9),_codeset),
unicode(locale.nl_langinfo(locale.ABMON_10),_codeset),
unicode(locale.nl_langinfo(locale.ABMON_11),_codeset),
unicode(locale.nl_langinfo(locale.ABMON_12),_codeset),
)
_tformat = locale.nl_langinfo(locale.D_FMT).replace('%y','%Y')
@ -231,9 +231,9 @@ class DateDisplay:
if date_val[1] == 0:
return year
else:
return "%s %s" % (self._MONS[date_val[1]],year)
return "%s %s" % (self._MONS[date_val[1]].upper(),year)
else:
return "%s %d, %s" % (self._MONS[date_val[1]],date_val[0],year)
return "%s %d, %s" % (self._MONS[date_val[1]].upper(),date_val[0],year)
elif self.format == 4:
# Day Month Year
if date_val[0] == 0:
@ -249,9 +249,9 @@ class DateDisplay:
if date_val[1] == 0:
return year
else:
return "%s %s" % (self._MONS[date_val[1]],year)
return "%s %s" % (self._MONS[date_val[1]].upper(),year)
else:
return "%d %s %s" % (date_val[0],self._MONS[date_val[1]],year)
return "%d %s %s" % (date_val[0],self._MONS[date_val[1]].upper(),year)
def _display_julian(self,date_val):
# Julian date display is the same as Gregorian

View File

@ -42,6 +42,31 @@ class DateParser:
# determine the code set returned by nl_langinfo
_codeset = locale.nl_langinfo(locale.CODESET)
_rfc_mons = (
unicode(locale.nl_langinfo(locale.ABMON_1),_codeset),
unicode(locale.nl_langinfo(locale.ABMON_2),_codeset),
unicode(locale.nl_langinfo(locale.ABMON_3),_codeset),
unicode(locale.nl_langinfo(locale.ABMON_4),_codeset),
unicode(locale.nl_langinfo(locale.ABMON_5),_codeset),
unicode(locale.nl_langinfo(locale.ABMON_6),_codeset),
unicode(locale.nl_langinfo(locale.ABMON_7),_codeset),
unicode(locale.nl_langinfo(locale.ABMON_8),_codeset),
unicode(locale.nl_langinfo(locale.ABMON_9),_codeset),
unicode(locale.nl_langinfo(locale.ABMON_10),_codeset),
unicode(locale.nl_langinfo(locale.ABMON_11),_codeset),
unicode(locale.nl_langinfo(locale.ABMON_12),_codeset),
)
_rfc_days = (
unicode(locale.nl_langinfo(locale.ABDAY_1),_codeset),
unicode(locale.nl_langinfo(locale.ABDAY_2),_codeset),
unicode(locale.nl_langinfo(locale.ABDAY_3),_codeset),
unicode(locale.nl_langinfo(locale.ABDAY_4),_codeset),
unicode(locale.nl_langinfo(locale.ABDAY_5),_codeset),
unicode(locale.nl_langinfo(locale.ABDAY_6),_codeset),
unicode(locale.nl_langinfo(locale.ABDAY_7),_codeset),
)
month_to_int = {
unicode(locale.nl_langinfo(locale.MON_1),_codeset).lower() : 1,
unicode(locale.nl_langinfo(locale.ABMON_1),_codeset).lower() : 1,
@ -149,6 +174,9 @@ class DateParser:
'calculated' : Date.QUAL_CALCULATED,
}
_rfc_mon_str = '(' + '|'.join(_rfc_mons) + ')'
_rfc_day_str = '(' + '|'.join(_rfc_days) + ')'
_qual_str = '(' + '|'.join(
[ key.replace('.','\.') for key in quality_to_int.keys() ]
) + ')'
@ -196,6 +224,8 @@ class DateParser:
re.IGNORECASE)
_numeric = re.compile("((\d+)[/\.])?((\d+)[/\.])?(\d+)")
_iso = re.compile("(\d+)-(\d+)-(\d+)")
_rfc = re.compile("%s,\s+(\d\d)\s+%s\s+(\d+)\s+\d\d:\d\d:\d\d\s+(\+|-)\d\d\d\d"
% (_rfc_day_str,_rfc_mon_str))
def __init__(self):
@ -300,6 +330,14 @@ class DateParser:
d = self._get_int(groups[2])
return (d,m,y,False)
match = self._rfc.match(text)
if match:
groups = match.groups()
d = self._get_int(groups[1])
m = self.month_to_int[groups[2].lower()]
y = self._get_int(groups[3])
return (d,m,y,False)
match = self._numeric.match(text)
if match:
groups = match.groups()