MCPcopy Index your code
hub / github.com/python-pendulum/pendulum / diff_for_humans

Method diff_for_humans

src/pendulum/date.py:293–329  ·  view source on GitHub ↗

Get the difference in a human readable format in the current locale. When comparing a value in the past to default now: 1 day ago 5 months ago When comparing a value in the future to default now: 1 day from now 5 months from now Whe

(
        self,
        other: date | None = None,
        absolute: bool = False,
        locale: str | None = None,
    )

Source from the content-addressed store, hash-verified

291 return Interval(self, Date(dt.year, dt.month, dt.day), absolute=abs)
292
293 def diff_for_humans(
294 self,
295 other: date | None = None,
296 absolute: bool = False,
297 locale: str | None = None,
298 ) -> str:
299 """
300 Get the difference in a human readable format in the current locale.
301
302 When comparing a value in the past to default now:
303 1 day ago
304 5 months ago
305
306 When comparing a value in the future to default now:
307 1 day from now
308 5 months from now
309
310 When comparing a value in the past to another value:
311 1 day before
312 5 months before
313
314 When comparing a value in the future to another value:
315 1 day after
316 5 months after
317
318 :param other: The date to compare to (defaults to today)
319 :param absolute: removes time difference modifiers ago, after, etc
320 :param locale: The locale to use for localization
321 """
322 is_now = other is None
323
324 if is_now:
325 other = self.today()
326
327 diff = self.diff(other)
328
329 return pendulum.format_diff(diff, is_now, absolute, locale)
330
331 # MODIFIERS
332

Callers

nothing calls this directly

Calls 2

todayMethod · 0.95
diffMethod · 0.95

Tested by

no test coverage detected