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

Method append

src/dateutil/parser/_parser.py:428–454  ·  view source on GitHub ↗
(self, val, label=None)

Source from the content-addressed store, hash-verified

426 return 1 <= value <= monthrange(year, month)[1]
427
428 def append(self, val, label=None):
429 if hasattr(val, '__len__'):
430 if val.isdigit() and len(val) > 2:
431 self.century_specified = True
432 if label not in [None, 'Y']: # pragma: no cover
433 raise ValueError(label)
434 label = 'Y'
435 elif val > 100:
436 self.century_specified = True
437 if label not in [None, 'Y']: # pragma: no cover
438 raise ValueError(label)
439 label = 'Y'
440
441 super(self.__class__, self).append(int(val))
442
443 if label == 'M':
444 if self.has_month:
445 raise ValueError('Month is already set')
446 self.mstridx = len(self) - 1
447 elif label == 'D':
448 if self.has_day:
449 raise ValueError('Day is already set')
450 self.dstridx = len(self) - 1
451 elif label == 'Y':
452 if self.has_year:
453 raise ValueError('Year is already set')
454 self.ystridx = len(self) - 1
455
456 def _resolve_from_stridxs(self, strids):
457 """

Callers 15

READMEFunction · 0.80
updatezinfo.pyFile · 0.80
__repr__Method · 0.80
_iter_cachedMethod · 0.80
betweenMethod · 0.80
__init__Method · 0.80
__str__Method · 0.80
_iterMethod · 0.80
rebuildMethod · 0.80
htimesetMethod · 0.80
mtimesetMethod · 0.80
__init__Method · 0.80

Calls

no outgoing calls

Tested by 7

test_YMD_could_be_dayFunction · 0.64
test_ybdMethod · 0.64
_generate_tzoffsetsFunction · 0.64
__make_date_examplesFunction · 0.64
__make_time_examplesFunction · 0.64
testIsStdMethod · 0.64