File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -174,6 +174,8 @@ def naturaldelta(
174174 minimum_unit (str): The lowest unit that can be used.
175175 when (datetime.datetime): Point in time relative to which _value_ is
176176 interpreted. Defaults to the current time in the local timezone.
177+ Deprecated in version 3.14; If you need to construct a timedelta,
178+ do it inline as the first argument.
177179
178180 Returns:
179181 str: A natural representation of the amount of time elapsed.
@@ -190,6 +192,14 @@ def naturaldelta(
190192
191193 assert naturaldelta(later, when=now) == "30 minutes"
192194 """
195+ if when :
196+ warnings .warn (
197+ "The `when` parameter of `naturaldelta()` is deprecated and will be "
198+ "removed in humanize 4.0. If you need to construct a timedelta, "
199+ "do it inline as the first argument." ,
200+ DeprecationWarning ,
201+ stacklevel = 2 ,
202+ )
193203 tmp = _Unit [minimum_unit .upper ()]
194204 if tmp not in (_Unit .SECONDS , _Unit .MILLISECONDS , _Unit .MICROSECONDS ):
195205 raise ValueError (f"Minimum unit '{ minimum_unit } ' not supported" )
You can’t perform that action at this time.
0 commit comments