Skip to content

Commit

Permalink
Minor arithemtic enhanements
Browse files Browse the repository at this point in the history
Use floor division instead of regular division follow by int() conversion. Also remove redundant parenthesis.

Taken from #2258 by @Mictronics.

Signed-off-by: MichaIng <micha@dietpi.com>
  • Loading branch information
MichaIng committed Mar 20, 2022
1 parent 559f42d commit 827d7a6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions motioneye/utils/dtconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def pretty_date_time(date_time, tzinfo=None, short=False):
tz += '-'
offset = -offset

tz += '%.2d' % (offset / 3600) + ':%.2d' % ((offset % 3600) / 60)
tz += '%.2d' % (offset // 3600) + ':%.2d' % ((offset % 3600) // 60)

text += ' (' + tz + ')'

Expand All @@ -77,8 +77,8 @@ def pretty_time(t: Union[datetime.time, datetime.timedelta]) -> str:
return ''

if isinstance(t, datetime.timedelta):
hour = int(t.seconds / 3600)
minute = int((t.seconds % 3600) / 60)
hour = t.seconds // 3600
minute = (t.seconds % 3600) // 60
t = datetime.time(hour=hour, minute=minute)

return '{hm}'.format(hm=t.strftime('%H:%M'))
Expand All @@ -98,11 +98,11 @@ def pretty_duration(duration):
else:
negative = False

days = int(duration / 86400)
days = duration // 86400
duration %= 86400
hours = int(duration / 3600)
hours = duration // 3600
duration %= 3600
minutes = int(duration / 60)
minutes = duration // 60
duration %= 60
seconds = duration

Expand Down

0 comments on commit 827d7a6

Please sign in to comment.