1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 """
31 Dutch-specific classes for parsing and displaying dates.
32 """
33
34
35
36
37
38
39 import re
40
41
42
43
44
45
46 from gen.lib import Date
47 from _DateParser import DateParser
48 from _DateDisplay import DateDisplay
49 from _DateHandler import register_datehandler
50
51
52
53
54
55
57
58 month_to_int = DateParser.month_to_int
59
60
61 month_to_int[u"januari"] = 1
62 month_to_int[u"jan"] = 1
63
64 month_to_int[u"januaris"] = 1
65 month_to_int[u"feber"] = 2
66 month_to_int[u"februaris"] = 2
67 month_to_int[u"merz"] = 3
68 month_to_int[u"aprilis"] = 4
69 month_to_int[u"maius"] = 5
70 month_to_int[u"junius"] = 6
71 month_to_int[u"julius"] = 7
72 month_to_int[u"augst"] = 8
73 month_to_int[u"7ber"] = 9
74 month_to_int[u"7bris"] = 9
75 month_to_int[u"8ber"] = 10
76 month_to_int[u"8bris"] = 10
77 month_to_int[u"9ber"] = 11
78 month_to_int[u"9bris"] = 11
79 month_to_int[u"10ber"] = 12
80 month_to_int[u"10bris"] = 12
81 month_to_int[u"xber"] = 12
82 month_to_int[u"xbris"] = 12
83
84 modifier_to_int = {
85 u'voor' : Date.MOD_BEFORE,
86 u'na' : Date.MOD_AFTER,
87 u'tegen' : Date.MOD_ABOUT,
88 u'om' : Date.MOD_ABOUT,
89 u'rond' : Date.MOD_ABOUT,
90 u'circa' : Date.MOD_ABOUT,
91 u'ca.' : Date.MOD_ABOUT,
92 }
93
94 calendar_to_int = {
95 u'gregoriaans' : Date.CAL_GREGORIAN,
96 u'greg.' : Date.CAL_GREGORIAN,
97 u'juliaans' : Date.CAL_JULIAN,
98 u'jul.' : Date.CAL_JULIAN,
99 u'hebreeuws' : Date.CAL_HEBREW,
100 u'hebr.' : Date.CAL_HEBREW,
101 u'islamitisch' : Date.CAL_ISLAMIC,
102 u'isl.' : Date.CAL_ISLAMIC,
103 u'franse republiek': Date.CAL_FRENCH,
104 u'fran.' : Date.CAL_FRENCH,
105 u'persisch' : Date.CAL_PERSIAN,
106 }
107
108 quality_to_int = {
109 u'geschat' : Date.QUAL_ESTIMATED,
110 u'gesch.' : Date.QUAL_ESTIMATED,
111 u'berekend' : Date.QUAL_CALCULATED,
112 u'ber.' : Date.QUAL_CALCULATED,
113 }
114
115 bce = ["voor onze tijdrekening", "voor Christus", "v. Chr."] + DateParser.bce
116
118 DateParser.init_strings(self)
119 self._span = re.compile("(van)\s+(?P<start>.+)\s+(tot)\s+(?P<stop>.+)",
120 re.IGNORECASE)
121 self._range = re.compile("tussen\s+(?P<start>.+)\s+en\s+(?P<stop>.+)",
122 re.IGNORECASE)
123 self._text2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?'
124 % self._mon_str,
125 re.IGNORECASE)
126 self._jtext2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?'
127 % self._jmon_str,
128 re.IGNORECASE)
129
130
131
132
133
134
136
137 calendar = (
138 "", u" (juliaans)", u" (hebreeuws)",
139 u" (franse republiek)", u" (persisch)", u" (islamitisch)"
140 )
141
142 _mod_str = ("", u"voor ", u"na ", u"rond ", "", "", "")
143
144 _qual_str = ("", u"geschat ", u"berekend ")
145
146 _bce_str = "%s v. Chr."
147
148 formats = (
149 "JJJJ-MM-DD (ISO)", "Numerisch DD/MM/JJ", "Maand Dag, Jaar",
150 "Mnd. Dag Jaar", "Dag Maand Jaar", "Dag Mnd. Jaar"
151 )
152
154 year = self._slash_year(date_val[2], date_val[3])
155 if self.format == 0:
156 return self.display_iso(date_val)
157 elif self.format == 1:
158 if date_val[3]:
159 return self.display_iso(date_val)
160 else:
161
162 if date_val[0] == 0 and date_val[1] == 0:
163 value = str(date_val[2])
164 else:
165 value = self._tformat.replace('%m', str(date_val[1]))
166 value = value.replace('%d', str(date_val[0]))
167 value = value.replace('%Y', str(abs(date_val[2])))
168 value = value.replace('-', '/')
169 elif self.format == 2:
170
171 if date_val[0] == 0:
172 if date_val[1] == 0:
173 value = year
174 else:
175 value = "%s %s" % (self._months[date_val[1]], year)
176 else:
177 value = "%s %d, %s" % (self._months[date_val[1]], date_val[0], year)
178 elif self.format == 3:
179
180 if date_val[0] == 0:
181 if date_val[1] == 0:
182 value = year
183 else:
184 value = "%s %s" % (self.MONS[date_val[1]], year)
185 else:
186 value = "%s %d, %s" % (self.MONS[date_val[1]], date_val[0], year)
187 elif self.format == 4:
188
189 if date_val[0] == 0:
190 if date_val[1] == 0:
191 value = year
192 else:
193 value = "%s %s" % (self._months[date_val[1]], year)
194 else:
195 value = "%d %s %s" % (date_val[0], self._months[date_val[1]], year)
196 else:
197
198 if date_val[0] == 0:
199 if date_val[1] == 0:
200 value = year
201 else:
202 value = "%s %s" % (self.MONS[date_val[1]], year)
203 else:
204 value = "%d %s %s" % (date_val[0], self.MONS[date_val[1]], year)
205 if date_val[2] < 0:
206 return self._bce_str % value
207 else:
208 return value
209
211 """
212 Return a text string representing the date.
213 """
214 mod = date.get_modifier()
215 cal = date.get_calendar()
216 qual = date.get_quality()
217 start = date.get_start_date()
218
219 qual_str = self._qual_str[qual]
220
221 if mod == Date.MOD_TEXTONLY:
222 return date.get_text()
223 elif start == Date.EMPTY:
224 return ""
225 elif mod == Date.MOD_SPAN:
226 d1 = self.display_cal[cal](start)
227 d2 = self.display_cal[cal](date.get_stop_date())
228 return "%s%s %s %s %s%s" % (qual_str, u'van', d1,
229 u'tot', d2, self.calendar[cal])
230 elif mod == Date.MOD_RANGE:
231 d1 = self.display_cal[cal](start)
232 d2 = self.display_cal[cal](date.get_stop_date())
233 return "%stussen %s en %s%s" % (qual_str, d1, d2,
234 self.calendar[cal])
235 else:
236 text = self.display_cal[date.get_calendar()](start)
237 return "%s%s%s%s" % (qual_str, self._mod_str[mod], text,
238 self.calendar[cal])
239
240
241
242
243
244
245 register_datehandler(('nl_NL', 'dutch', 'nl_BE', 'nl'),
246 DateParserNL, DateDisplayNL)
247