Created
August 31, 2011 19:13
-
-
Save topfunky/1184434 to your computer and use it in GitHub Desktop.
A custom Batman.js filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Transform an integer number of seconds as hours and minutes: 1:45 | |
# | |
# Put in filters/duration.coffee and do @require('filters', 'duration') | |
Batman.Filters.formatSecondsAsTime = (value) -> | |
seconds = parseInt value, 10 | |
return '' unless seconds | |
hours = parseInt seconds / 60 / 60, 10 | |
minutes = parseInt (seconds / 60) % 60, 10 | |
hours = '' unless hours > 0 | |
minutes = '0' + minutes if minutes < 10 | |
[hours, minutes].join ':' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
:-D