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

Method convertyear

src/dateutil/parser/_parser.py:360–378  ·  view source on GitHub ↗

Converts two-digit years to year within [-50, 49] range of self._year (current local time)

(self, year, century_specified=False)

Source from the content-addressed store, hash-verified

358 return self.TZOFFSET.get(name)
359
360 def convertyear(self, year, century_specified=False):
361 """
362 Converts two-digit years to year within [-50, 49]
363 range of self._year (current local time)
364 """
365
366 # Function contract is that the year is always positive
367 assert year >= 0
368
369 if year < 100 and not century_specified:
370 # assume current century to start
371 year += self._century
372
373 if year >= self._year + 50: # if too far in future
374 year -= 100
375 elif year < self._year - 50: # if too far in past
376 year += 100
377
378 return year
379
380 def validate(self, res):
381 # move to info

Callers 4

validateMethod · 0.95
_parseMethod · 0.80
test_convertyearFunction · 0.80

Calls

no outgoing calls

Tested by 2

test_convertyearFunction · 0.64