pydit.wrangling.date_time_calculations.date_relative_in_words¶
- pydit.wrangling.date_time_calculations.date_relative_in_words(input_date, reference_datetime: datetime | None = None) str[source]¶
Return a human description of how many months ago or in the future a date occurred/occurs.
- Parameters:
input_date (str or datetime) – The date to compare to the reference date. Can be a string or a datetime object.
reference_datetime (datetime, optional) – The date to compare the input_date to. If None, the current date and time will be used.
- Returns:
A human-readable string describing how long ago or in the future the input_date is relative to the reference_datetime. Possible outputs include “within a week ago”, “in 3 days”, “2 months ago”, “in more than two years”, etc.
- Return type:
str