You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add CrossHair support for dateutil.relativedelta, so programs doing calendar-field
date math (+ relativedelta(months=1), + relativedelta(years=1), weekday
targeting) can be analyzed and have counterexamples found.
Dependencies
Blocked by the lazy/optional-module registration issue � dateutil is a
third-party, optional dependency, so we need import-triggered registration before
a dateutillib.py can exist cleanly.
timedelta is pure day/second offsets and is now linear on the ordinal (#428). relativedelta is different: it does calendar-field arithmetic � add N months or
years, with day-clamping (Jan 31 + relativedelta(months=1) � Feb 28/29), and
relative weekday targeting. This is intrinsically calendar-nonlinear (month lengths,
leap years, boundary wrap) and unsupported today (no dateutil patching exists).
Proposal
New crosshair/libimpl/dateutillib.py registered lazily on import dateutil�.
Patch relativedelta construction and its __add__/__radd__/__sub__ against date/datetime.
Split the arithmetic: the absolute part (days, weeks, plus normalized
hours/minutes/seconds/microseconds) reuses ordinal/total-micros arithmetic from Represent symbolic dates by ordinal, decomposing calendar fields lazily #428; the relative part (years, months, day-clamping, weekday) is the
nonlinear core to model carefully � decide per field what stays symbolic vs.
realizes.
Where this lives
New crosshair/libimpl/dateutillib.py (+ a _ch_test.py mirroring datetimelib_ch_test.py round-trips against real dateutil).
Hooks into the registration mechanism from the prerequisite issue.
Summary
Add CrossHair support for
dateutil.relativedelta, so programs doing calendar-fielddate math (
+ relativedelta(months=1),+ relativedelta(years=1), weekdaytargeting) can be analyzed and have counterexamples found.
Dependencies
dateutilis athird-party, optional dependency, so we need import-triggered registration before
a
dateutillib.pycan exist cleanly.portion of
relativedeltarides on the now-linear ordinal arithmetic.Motivation
timedeltais pure day/second offsets and is now linear on the ordinal (#428).relativedeltais different: it does calendar-field arithmetic � add N months oryears, with day-clamping (
Jan 31 + relativedelta(months=1)� Feb 28/29), andrelative weekday targeting. This is intrinsically calendar-nonlinear (month lengths,
leap years, boundary wrap) and unsupported today (no
dateutilpatching exists).Proposal
crosshair/libimpl/dateutillib.pyregistered lazily onimport dateutil�.relativedeltaconstruction and its__add__/__radd__/__sub__againstdate/datetime.hours/minutes/seconds/microseconds) reuses ordinal/total-micros arithmetic from
Represent symbolic dates by ordinal, decomposing calendar fields lazily #428; the relative part (years, months, day-clamping, weekday) is the
nonlinear core to model carefully � decide per field what stays symbolic vs.
realizes.
Where this lives
crosshair/libimpl/dateutillib.py(+ a_ch_test.pymirroringdatetimelib_ch_test.pyround-trips against realdateutil).Implementation sketch (phased)
crosshair-benchmarkcase, e.g. afalsifiable contract over
d + relativedelta(months=1).relativedelta(days/weeks/H:M:S) on the ordinal base � shouldbe ~linear.
realization policy where needed.
relativedelta(date1, date2)diff form.Risks / things to measure
linear like
timedelta. Gate each phase on benchmarks.relativedeltamust round-trip against the reallibrary.
Acceptance criteria
date/datetime+/-relativedelta(...)finds counterexamples and matchesdateutilon a CrossHair-on-CrossHair round-trip suite.(months/years) is at least tractable with no regression elsewhere.
dateutilinstalled.References