Skip to content

Instantly share code, notes, and snippets.

@topfunky
Created August 31, 2011 19:13
Show Gist options
  • Save topfunky/1184434 to your computer and use it in GitHub Desktop.
Save topfunky/1184434 to your computer and use it in GitHub Desktop.
A custom Batman.js filter
# 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 ':'
@tobi
Copy link

tobi commented Aug 31, 2011

:-D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment