Changes

Jump to: navigation, search

Dates

131 bytes added, 13:48, 28 October 2013
Related Gramps bugs: new subsection, rework to use Template:bug
[[Category:Developers/General]][[Category:Documentation]]
 
This page documents advanced features of GRAMPS dates.
From [2]: "For example, England and the American colonies didn't officially accept the new calendar until 1752. Before 1752, the English government still observed March 25 as the first of the year, but most of the population observed January 1 as the first of the year. For this reason, many people wrote dates falling between January 1 and March 25 with both years..."
Sometimes, a dual date may appear as a fraction, as in this grave stone (170 and 3/4, which means 1703 and 1704):
[[Image:Gravestone.jpg]]
<pre>
> dates = ["Dec 31, 1720", "Jan 1, 1720", "Mar 1, 1720", "Mar 25, 1720", "Mar 26, 1720", "Dec 1, 1720"]
> dates.sort(cmpkey=lambda a,bx: cmp(Date(a).sortval, Date(b).sortvalx))
> dates
['Jan 1, 1720', 'Mar 1, 1720', 'Mar 25, 1720', 'Mar 26, 1720', 'Dec 1, 1720', 'Dec 31, 1720']
> dates.sort(cmpkey=lambda a,bx: cmp(Date(a x + " (Mar25)").sortval, Date(b + " (Mar25)").sortval))
> dates
['Mar 25, 1720', 'Mar 26, 1720', 'Dec 1, 1720', 'Jan 1, 1720', 'Dec 31, 1720', 'Mar 1, 1720']
</pre>
This creates a list of date strings. You can sort them by wrapping Date() around them, and using their sortvalcomparing to another Date. In the first example, they have a normal, January through December ordering.
In the second example we append a " (Mar25)" after the date. Now when we sort, we see that the year begins with Mar, followed by all of the months up to Dec, then Jan, Feb and the first part of March is last.
# for describing (eg, for describing an age)
# for ranking (eg, for computing "record holding" spans)
 
=== Date Differences ===
When a date is subtracted from another, a Span is created. A date Span can be used for creating a textual representation of the difference. A Span can also be used for ranking the difference, including a minimum difference, and a maximum difference.
=== Date Comparisons === There are three methods for comparing datesseeing if one date happened before another date:
# simple method: date1.sortval < date2.sortval
# more restrictive: date1.match(date2, "<<")
Likewise for seeing if two dates are the same: # simple method: date1.sortval = TODO =date2.sortval# more sophisticated and expensive: date1.match(date2' "=") and for seeing if one date happened after another date: # simple method: date1.sortval > date2.sortval# more sophisticated and expensive: date1.match(date2' ">")# more restrictive: date1.match(date2, ">>") 
# Add more tests to date_test.py
# Get feedback from developers
# Update any translations, or other date parsers/displayers
# Update the XML import/export plugins
# Updated the DTD
= References =
# http://www.genealogy.com/00000771.html
# http://en.wikipedia.org/wiki/New_Year
# http://www.gramps-project.org/==Related Gramps bugs/view.php?id==# <s>{{bug|1133 - 0001133}}</s>: Dates in Event view do not display in chronological order # http://www.gramps-project.org/bugs<s>{{bug|1834}}</view.php?id=1834 - 0001834s>: Dates do not respect new-year boundaries in history # http://www.gramps-project.org/bugs<s>{{bug|1842}}</view.php?id=1842 - 0001842s>: Editing double-dated dates (slash) in GUI box loses slash # http://www.gramps-project.org/bugs<s>{{bug|2260}}</view.php?id=2260 - 0002260s>: fractional year dates not interpreted correctly
296
edits

Navigation menu