Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duration template function outputs possibly in accurate time. #4

Open
aradlein opened this issue Sep 7, 2012 · 0 comments
Open

Duration template function outputs possibly in accurate time. #4

aradlein opened this issue Sep 7, 2012 · 0 comments

Comments

@aradlein
Copy link

aradlein commented Sep 7, 2012

Inside of the duration function, used to describe the time_spent attribute on the events tab, it takes in a value which is interpreted as a second at the beginning and then is divided by 60 for some reason down below:

@register.filter
def duration(value):
if not value:
return '0s'
hours, minutes, seconds = 0, 0, 0
if value > 3600:
hours = value / 3600
value = value % 3600
if value > 60:
minutes = value / 60
value = value % 60
seconds = value / 60
output = []
if hours:
output.append('%dh' % hours)
if minutes:
output.append('%dm' % minutes)
if seconds > 1:
output.append('%0.2fs' % seconds)
elif seconds:
output.append('%dms' % (seconds * 1000))
return ''.join(output)

The culprit is the line "seconds = value / 60", as at this point it seems to already be in seconds. For instance, if you pass the value 1 in ( I'm assuming it's 1s ) , the interface would display 16ms , which I don't believe is correct unless the original value is supposed to be something else that I can't figure out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant