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

Method append

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

Source from the content-addressed store, hash-verified

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

Callers 15

__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
rruleMethod · 0.80
rdateMethod · 0.80

Calls

no outgoing calls

Tested by 15

test_YMD_could_be_dayFunction · 0.64
_probe_instantsFunction · 0.64
_parse_tzdata_ziFunction · 0.64
test_ybdMethod · 0.64
construct_zoneFunction · 0.64
add_casesFunction · 0.64
_one_transitionFunction · 0.64
_one_transition_foldFunction · 0.64