+- `relative_time(datetime, is_future=False, depth=1)` converts datetime object to its human-friendly time string. The time string can be in seconds, minutes, hours, days, months, and years. `is_future` determines if the datetime is in the future or not. If `is_future` is left at its default of False, only datetimes in the past may be used, otherwise, the unmodified datetime object is returned. If `is_future` is True, future datetimes may be used. In this case, if the datetime is in the past, the string "0 seconds" is returned. `depth` indicates the number of units returned with the last unit rounded (i.e `depth = 1` could return "2 years" while `depth = 2` could return "1 year 11 months"). This function can also be used as a filter.
0 commit comments