defparse_timedelta_or_passthrough(v):""" We pass the value to the native pydantic validator if the value does not match our pattern. """ifvandisinstance(v,str)andtime_duration_pattern.match(v):returnparse_time_duration(v)returnv
defensure_timezone_aware(v:Optional[datetime]):"""Ensure datetime is timezone-aware by defaulting to UTC."""ifvisNone:returnvifv.tzinfoisNone:returnv.replace(tzinfo=UTC)returnv