From 3110e13240ee921811cbe3f512515fec39d68c4d Mon Sep 17 00:00:00 2001 From: Yasser-Ameur Date: Thu, 26 Nov 2026 11:05:18 +0100 Subject: [PATCH] Fix Interval.in_words() singular unit for sub-second intervals Interval.in_words() returned "0.12 second" for an interval of 123456 microseconds, while Duration.in_words() returns "0.12 seconds". #826 changed the sub-second branch of Duration.in_words() to use plural(0), but Interval overrides in_words() with its own copy of that code, which still used plural(1). Its test asserted the old singular. Use plural(0) in Interval.in_words(), as Duration does, and update the test expectation to "0.12 seconds". --- src/pendulum/interval.py | 2 +- tests/interval/test_in_words.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pendulum/interval.py b/src/pendulum/interval.py index c5e0713a7..12d73e328 100644 --- a/src/pendulum/interval.py +++ b/src/pendulum/interval.py @@ -277,7 +277,7 @@ def in_words(self, locale: str | None = None, separator: str = " ") -> str: if not parts: count: str | int = 0 if abs(self.microseconds) > 0: - unit = f"units.second.{loaded_locale.plural(1)}" + unit = f"units.second.{loaded_locale.plural(0)}" count = f"{abs(self.microseconds) / 1e6:.2f}" else: unit = f"units.microsecond.{loaded_locale.plural(0)}" diff --git a/tests/interval/test_in_words.py b/tests/interval/test_in_words.py index f60e20d04..9c83ac84f 100644 --- a/tests/interval/test_in_words.py +++ b/tests/interval/test_in_words.py @@ -53,7 +53,7 @@ def test_subseconds(): interval = pendulum.interval( start=start_date, end=start_date.add(microseconds=123456) ) - assert interval.in_words() == "0.12 second" + assert interval.in_words() == "0.12 seconds" def test_subseconds_with_seconds():