Skip to content

Commit

Permalink
Add a leading 0 to the duration subparts
Browse files Browse the repository at this point in the history
  • Loading branch information
Benoît Allard committed Dec 11, 2014
1 parent 6d084c7 commit 3845208
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions www/base/src/app/common/filters/moment/moment.filter.coffee
Expand Up @@ -12,14 +12,20 @@ class Durationformat extends Filter('common')
constructor: (MOMENT) ->
return (time) ->
d = MOMENT.duration(time * 1000)
mins = d.minutes()
if mins < 10
mins = '0' + mins
secs = d.seconds()
if secs < 10
secs = '0' + secs
if d.hours()
return "#{d.hours()}:#{d.minutes()}:#{d.seconds()}"
return "#{d.hours()}:#{mins}:#{secs}"
else if d.minutes()
return "#{d.minutes()}:#{d.seconds()}"
return "#{d.minutes()}:#{secs}"
else
return "#{d.seconds()}s"

class Dateformat extends Filter('common')
constructor: (MOMENT) ->
return (time, f) ->
return MOMENT.unix(time).format(f)
return MOMENT.unix(time).format(f)

0 comments on commit 3845208

Please sign in to comment.