Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/pendulum/duration.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def in_minutes(self) -> int:
def in_seconds(self) -> int:
return int(self.total_seconds())

def in_words(self, locale: str | None = None, separator: str = " ") -> str:
def in_words(self, locale: str | None = None, separator: str = " ") -> str:
"""
Get the current interval in words in the current locale.

Expand Down Expand Up @@ -273,8 +273,8 @@ def in_words(self, locale: str | None = None, separator: str = " ") -> str:

if not parts:
count: int | str = 0
if abs(self.microseconds) > 0:
unit = f"units.second.{loaded_locale.plural(1)}"
if self.microseconds != 0:
unit = f"units.second.{loaded_locale.plural(0)}"
count = f"{abs(self.microseconds) / 1e6:.2f}"
else:
unit = f"units.microsecond.{loaded_locale.plural(0)}"
Expand Down
3 changes: 1 addition & 2 deletions tests/duration/test_in_words.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,11 @@ def test_separator():
def test_subseconds():
pi = pendulum.duration(microseconds=123456)

assert pi.in_words() == "0.12 second"
assert pi.in_words() == "0.12 seconds"


def test_subseconds_with_seconds():
pi = pendulum.duration(seconds=12, microseconds=123456)

assert pi.in_words() == "12 seconds"


Expand Down
Loading