MCPcopy Create free account
hub / github.com/dateutil/dateutil / parserinfo

Class parserinfo

src/dateutil/parser/_parser.py:235–385  ·  view source on GitHub ↗

Class which handles what inputs are accepted. Subclass this to customize the language and acceptable values for each parameter. :param dayfirst: Whether to interpret the first value in an ambiguous 3-integer date (e.g. 01/05/09) as the day (``True``) or month (``False``

Source from the content-addressed store, hash-verified

233
234
235class parserinfo:
236 """
237 Class which handles what inputs are accepted. Subclass this to customize
238 the language and acceptable values for each parameter.
239
240 :param dayfirst:
241 Whether to interpret the first value in an ambiguous 3-integer date
242 (e.g. 01/05/09) as the day (``True``) or month (``False``). If
243 ``yearfirst`` is set to ``True``, this distinguishes between YDM
244 and YMD. Default is ``False``.
245
246 :param yearfirst:
247 Whether to interpret the first value in an ambiguous 3-integer date
248 (e.g. 01/05/09) as the year. If ``True``, the first number is taken
249 to be the year, otherwise the last number is taken to be the year.
250 Default is ``False``.
251 """
252
253 # m from a.m/p.m, t from ISO T separator
254 JUMP = [" ", ".", ",", ";", "-", "/", "'",
255 "at", "on", "and", "ad", "m", "t", "of",
256 "st", "nd", "rd", "th"]
257
258 WEEKDAYS = [("Mon", "Monday"),
259 ("Tue", "Tuesday"), # TODO: "Tues"
260 ("Wed", "Wednesday"),
261 ("Thu", "Thursday"), # TODO: "Thurs"
262 ("Fri", "Friday"),
263 ("Sat", "Saturday"),
264 ("Sun", "Sunday")]
265 MONTHS = [("Jan", "January"),
266 ("Feb", "February"), # TODO: "Febr"
267 ("Mar", "March"),
268 ("Apr", "April"),
269 ("May", "May"),
270 ("Jun", "June"),
271 ("Jul", "July"),
272 ("Aug", "August"),
273 ("Sep", "Sept", "September"),
274 ("Oct", "October"),
275 ("Nov", "November"),
276 ("Dec", "December")]
277 HMS = [("h", "hour", "hours"),
278 ("m", "minute", "minutes"),
279 ("s", "second", "seconds")]
280 AMPM = [("am", "a"),
281 ("pm", "p")]
282 UTCZONE = ["UTC", "GMT", "Z", "z"]
283 PERTAIN = ["of"]
284 TZOFFSET = {}
285 # TODO: ERA = ["AD", "BC", "CE", "BCE", "Stardate",
286 # "Anno Domini", "Year of Our Lord"]
287
288 def __init__(self, dayfirst=False, yearfirst=False):
289 self._jump = self._convert(self.JUMP)
290 self._weekdays = self._convert(self.WEEKDAYS)
291 self._months = self._convert(self.MONTHS)
292 self._hms = self._convert(self.HMS)

Callers 3

test_convertyearFunction · 0.90
__init__Method · 0.85

Calls

no outgoing calls

Tested by 2

test_convertyearFunction · 0.72