Skip to content

Commit ebe7e79

Browse files
committed
Apply suggestions from code review
Separating out fix from adding seoncds_n_decimal
1 parent 95d75fc commit ebe7e79

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/pendulum/duration.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ def in_words(
242242
self,
243243
locale: str | None = None,
244244
separator: str = " ",
245-
seconds_n_decimal: int = 2,
246245
) -> str:
247246
"""
248247
Get the current interval in words in the current locale.
@@ -251,9 +250,6 @@ def in_words(
251250
252251
:param locale: The locale to use. Defaults to current locale.
253252
:param separator: The separator to use between each unit
254-
:param kwargs: Additional keyword arguments.
255-
- seconds_n_decimal (int): The number of decimal places to use for seconds if no other time units are present. Defaults to 2.
256-
257253
"""
258254
intervals = [
259255
("year", self.years),
@@ -281,10 +277,11 @@ def in_words(
281277

282278
if not parts:
283279
count: int | str = 0
284-
unit = f"units.second.{loaded_locale.plural(0)}"
280+
unit: str
285281
if self.microseconds != 0:
282+
unit = f"units.second.{loaded_locale.plural(0)}"
286283
microseconds = abs(self.microseconds) / 1e6
287-
count = str({round(microseconds, ndigits=seconds_n_decimal)})
284+
count = f"{abs(self.microseconds) / 1e6:.2f}"
288285
else:
289286
unit = f"units.microsecond.{loaded_locale.plural(0)}"
290287
translation = loaded_locale.translation(unit)

0 commit comments

Comments
 (0)