Debian Codegraph @

reports/dates.ll

raw
1 /*
2 * @progname dates.ll
3 * @version 4
4 * @author Eggert
5 * @category
6 * @output Text
7 * @description
8
9 Prints out the value of all the lines in your database with the DATE
10 tag, along with enough information so you can find the line easily.
11 The purpose of this report is so you can sort all the dates in the
12 database, so you can look for illegal dates, make birthday lists, etc.
13 The dates are printed in the order that they appear in the database,
14 Output can then be sorted if this is more useful than the native form.
15
16 dates - a LifeLines dates extraction program
17 by Jim Eggert ([email protected])
18 Version 1, 3 December 1992
19 Version 2, 8 December 1992 (minor bug fix, report in columns)
20 Version 3, 5 February 1993 (speedup of tag handling)
21 Version 4, 1 September 1993 (bug fix for families with no parents)
22
23 This code borrows heavily from the excellent program places, written
24 by David Olsen ([email protected]), and contains improvements by Steve
25 Woodbridge ([email protected]).
26
27 Prints out the value of all the lines in your database with the DATE
28 tag, along with enough information so you can find the line easily.
29 The purpose of this report is so you can sort all the dates in the
30 database, so you can look for illegal dates, make birthday lists, etc.
31 The dates are printed in the order that they appear in the database,
32 so the report is not very useful in its native form. To make it more
33 useful, run the output file through the program 'sort', and perhaps
34 'grep' if you want to get only birthdates etc. To make sorting
35 easier, each date is preceded by a eight-digit number of the form
36 yyyymmdd. Then a simple ASCII line-by-line sort puts the dates in the
37 right order. Days and months are checked for validity (thirty days
38 hath September and all that) and futurity. It asks you if you want to
39 use the Gregorian calendar or the Julian calendar. This only affects
40 the validity of Feb 29ths, so don't fret too much. Any invalid or
41 future date is marked with a * as the first character of the line.
42 These will appear first in the sorted output.
43
44 If the date is part of an individual record, it is followed by the key
45 and name of the individual and by the hierarchy of tags between it and
46 the INDI tag. (This is usually just a single tag, such as BIRT, CHR,
47 or DEAT.) If the date is part of a family record, it is followed by
48 the key and name of the husband (or the wife is there is no husband,
49 or first child if there is no parent), the relationship in the family
50 of that person, and by the hierarchy of tags between it and the FAM
51 tag. (This is usually just the single tag MARR.) Some sample output
52 (selected lines that have been sorted):
53
54 15800000 ABT 1580 | BIRT | I4403 Valentin BISMARCK
55 15810000 1581 | DEAT | I41 Catherina
56 15821221 21 DEC 1582 | BIRT | I4404 Berta ASSEBURG
57 15850000 ABT 1585 | BIRT | I2595 Henrich SPANUTH
58 15850529 29 MAY 1585 | DEAT | I4418 Brigitte BISMARCK
59 15860000 1586 | BIRT | I2596 Johan SPANUTH
60 15860301 1 MAR 1586 | BIRT | I2675 Catharine SPANUTH
61 15870000 1587/1589 | BIRT | I2597 Caspar SPANUTH
62 15880201 1 FEB 1588 | BIRT | I2676 Johan SPANUTH
63 15890226 26 FEB 1589 | BIRT | I2677 Johan SPANUTH
64 15960000 1596 | MARR | F883 I2679 Arend KOLLE, husb
65 16421009 9 OCT 1642 | BURI | I4404 Berta ASSEBURG
66 19800108 8 JAN 1980 | ENDL | I3635 Maria Catharina KINDLER
67 19800124 24 JAN 1980 | CHIL SLGC | F948 I2336 Anselm KINDLER, husb
68
69 */
70
71 global(today)
72 global(tomonth)
73 global(toyear)
74 global(julian)
75
76 proc do_date(datenode)
77 {
78 extractdate(datenode,day,month,year)
79 if (or(le(month,0),gt(month,12))) { set(daysinmonth,0) }
80 elsif (or(or(eq(month,9),eq(month,4)),
81 or(eq(month,6),eq(month,11)))) { set(daysinmonth,30) }
82 elsif (eq(month,2)) {
83 if (and(eq(mod(year,4),0),
84 or(julian,or(ne(mod(year,100),0),eq(mod(year,400),0))))) {
85 set(daysinmonth,29) }
86 else { set(daysinmonth,28) }
87 }
88 else { set(daysinmonth,31) }
89 set(future,0)
90 if (gt(year,toyear)) { set(future,1) }
91 elsif (eq(year,toyear)) {
92 if (gt(month,tomonth)) { set(future,1) }
93 elsif (and(eq(month,tomonth),gt(day,today))) { set(future,1) }
94 }
95 if (or(gt(day,daysinmonth),future)) { "*" }
96 if (lt(year,0)) { d(year) }
97 else {
98 if (lt(year,10)) { "0" }
99 if (lt(year,100)) { "0" }
100 if (lt(year,1000)) { "0" }
101 d(year)
102 }
103 if (lt(month,10)) { "0" }
104 d(month)
105 if (lt(day,10)) { "0" }
106 d(day) " "
107 }
108
109
110 proc main()
111 {
112 getintmsg(julian,
113 "Enter 0 for Gregorian (normal) or 1 for Julian (old) calendar")
114 extractdate(gettoday(),today,tomonth,toyear)
115
116 list(tag_stack)
117
118 print("Printing all dates.\n")
119 print("Be patient. This may take a while.\n")
120
121 forindi (person, pnum) {
122
123 traverse (inode(person), node, level) {
124
125 setel(tag_stack, add(level, 1), tag(node))
126
127 if (eq(strcmp(tag(node), "DATE"), 0)) {
128 call do_date(node)
129 value(node) col(31) "| "
130 set(tlength,0)
131 set(tcount,0)
132 forlist (tag_stack, a_tag, tnum) {
133 if (and(gt(tnum, 1), le(tnum, level))) {
134 a_tag " "
135 set(tlength,add(tlength,strlen(a_tag)))
136 set(tcount,add(tcount,1))
137 }
138 }
139 set(tlength,add(tlength,tcount))
140 if (lt(tlength,5)) { col(38) }
141 "| " key(person)
142 col(add(41,mul(5,tcount))) name(person) "\n"
143 }
144 }
145 }
146 forfam (fam, fnum) {
147 traverse (fnode(fam), node, level) {
148
149 setel(tag_stack, add(level, 1), tag(node))
150
151 if (eq(strcmp(tag(node), "DATE"), 0)) {
152 call do_date(node)
153 value(node) col(31) "| "
154 set(tlength,0)
155 set(tcount,0)
156 forlist (tag_stack, a_tag, tnum) {
157 if (and(gt(tnum, 1), le(tnum, level))) {
158 a_tag " "
159 set(tlength,add(tlength,strlen(a_tag)))
160 set(tcount,add(tcount,1))
161 }
162 }
163 set(tlength,add(tlength,tcount))
164 if (lt(tlength,5)) { col(38) }
165 "| " key(fam)
166 if (person,husband(fam)) { set(relation,", husb") }
167 elsif (person,wife(fam)) { set(relation,", wife") }
168 else {
169 children(fam,child,cnum) {
170 if (eq(cnum,1)) {
171 set(person,child)
172 set(relation,", chil")
173 }
174 }
175 }
176 if (person) {
177 col(add(41,mul(5,tcount))) key(person) " "
178 col(add(47,mul(5,tcount))) name(person) relation
179 }
180 "\n"
181 }
182 }
183 }
184 }