mirror of
https://github.com/wakatime/sublime-wakatime.git
synced 2023-08-10 21:13:02 +03:00
fixed bugs in away() function when building duration for popup.
This commit is contained in:
parent
64f95e28f0
commit
6b7eadb30e
@ -71,19 +71,24 @@ def api(targetFile, timestamp, isWrite=False, endtime=None):
|
|||||||
|
|
||||||
def away(now):
|
def away(now):
|
||||||
duration = now - LAST_USAGE
|
duration = now - LAST_USAGE
|
||||||
units = 'seconds'
|
minutes = ''
|
||||||
if duration > 59:
|
units = 'second'
|
||||||
|
if duration >= 60:
|
||||||
duration = int(duration / 60)
|
duration = int(duration / 60)
|
||||||
units = 'minutes'
|
units = 'minute'
|
||||||
if duration > 59:
|
if duration >= 60:
|
||||||
|
remainder = duration % 60
|
||||||
|
if remainder > 0:
|
||||||
|
minutes = ' and %d minute' % remainder
|
||||||
|
if remainder > 1:
|
||||||
|
minutes = minutes + 's'
|
||||||
duration = int(duration / 60)
|
duration = int(duration / 60)
|
||||||
units = 'hours'
|
units = 'hour'
|
||||||
if duration > 24:
|
if duration > 1:
|
||||||
duration = int(duration / 24)
|
units = units + 's'
|
||||||
units = 'days'
|
|
||||||
return sublime\
|
return sublime\
|
||||||
.ok_cancel_dialog("You were away %d %s. Add time to current file?"\
|
.ok_cancel_dialog("You were away %d %s%s. Add time to current file?"\
|
||||||
% (duration, units), 'Yes, log this time')
|
% (duration, units, minutes), 'Yes, log this time')
|
||||||
|
|
||||||
|
|
||||||
def enough_time_passed(now):
|
def enough_time_passed(now):
|
||||||
|
Loading…
Reference in New Issue
Block a user