forked from GithubBackups/healthchecks
Show sub-second durations with higher precision, 2 digits after decimal point. Fixes #321
This commit is contained in:
parent
77033760f9
commit
cdad632082
@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.
|
||||
- createsuperuser management command requires an unique email address (#318)
|
||||
- For superusers, show "Site Administration" in top navigation, note in README (#317)
|
||||
- Make Ping.body size limit configurable (#301)
|
||||
- Show sub-second durations with higher precision, 2 digits after decimal point (#321)
|
||||
|
||||
### Bug Fixes
|
||||
- Increase the allowable length of Matrix room alias to 100 (#320)
|
||||
|
@ -37,8 +37,11 @@ def format_duration(td):
|
||||
|
||||
|
||||
def format_hms(td):
|
||||
total_seconds = int(td.total_seconds())
|
||||
total_seconds = td.total_seconds()
|
||||
if 0.01 <= total_seconds < 1:
|
||||
return "%.2f sec" % total_seconds
|
||||
|
||||
total_seconds = int(total_seconds)
|
||||
result = []
|
||||
|
||||
mins, secs = divmod(total_seconds, 60)
|
||||
|
@ -5,6 +5,10 @@ from hc.lib.date import format_hms, choose_next_report_date
|
||||
|
||||
|
||||
class DateFormattingTestCase(TestCase):
|
||||
def test_sub_second_works(self):
|
||||
s = format_hms(td(seconds=0.12))
|
||||
self.assertEqual(s, "0.12 sec")
|
||||
|
||||
def test_mins_secs_work(self):
|
||||
s = format_hms(td(seconds=0))
|
||||
self.assertEqual(s, "0 sec")
|
||||
|
Loading…
x
Reference in New Issue
Block a user