HumanTimedelta#
- type safir.pydantic.HumanTimedelta = Annotated[datetime.timedelta, pydantic.functional_validators.BeforeValidator(func=safir.pydantic._types._validate_human_timedelta, json_schema_input_type=PydanticUndefined), pydantic.functional_serializers.PlainSerializer(func=safir.pydantic._types.<lambda>, return_type=float, when_used=json)]#
Parse a human-readable string into a
datetime.timedelta.Accepts as input an integer or float (or stringified integer or float) number of seconds, an already-parsed
timedelta, or a string consisting of one or more sequences of numbers and duration abbreviations, separated by optional whitespace. Whitespace at the beginning and end of the string is ignored. The supported abbreviations are:Week:
weeks,week,wDay:
days,day,dHour:
hours,hour,hr,hMinute:
minutes,minute,mins,min,mSecond:
seconds,second,secs,sec,s
If several are present, they must be given in the above order. Example valid strings are
8d(8 days),4h 3minutes(four hours and three minutes), and5w4d(five weeks and four days).