Skip to content

Commit

Permalink
Merge pull request #134 from hugovk/fix-fractional-0.333
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk authored Jun 20, 2020
2 parents c8af6a1 + b6040db commit 50dc5d7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ If seconds are too large, set `minimum_unit` to milliseconds or microseconds:
>>> humanize.fractional(0.3)
'3/10'
>>> humanize.fractional(0.333)
'1/3'
'333/1000'
>>> humanize.fractional(1)
'1'
```
Expand Down Expand Up @@ -151,13 +151,13 @@ How to change locale at runtime:
>>> import humanize
>>> import datetime as dt
>>> humanize.naturaltime(dt.timedelta(seconds=3))
3 seconds ago
'3 seconds ago'
>>> _t = humanize.i18n.activate("ru_RU")
>>> humanize.naturaltime(dt.timedelta(seconds=3))
3 секунды назад
'3 секунды назад'
>>> humanize.i18n.deactivate()
>>> humanize.naturaltime(dt.timedelta(seconds=3))
3 seconds ago
'3 seconds ago'
```

You can pass additional parameter `path` to `activate` to specify a path to search
Expand Down
4 changes: 4 additions & 0 deletions tests/test_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ def test_apnumber(test_input, expected):
("8.9", "8 9/10"),
("ten", "ten"),
(None, None),
(1 / 3, "1/3"),
(1.5, "1 1/2"),
(0.3, "3/10"),
(0.333, "333/1000"),
],
)
def test_fractional(test_input, expected):
Expand Down

0 comments on commit 50dc5d7

Please sign in to comment.