Created
April 3, 2015 14:09
-
-
Save manufitoussi/540fc556bb632a461d25 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function(value) { | |
if (Em.isNone(value)) { | |
return null; | |
} | |
var dur = moment.duration(value, 'seconds'); | |
var years = dur.years(); | |
var months = dur.months(); | |
var days = dur.days(); | |
var hours = dur.hours(); | |
var minutes = dur.minutes(); | |
var strTab = []; | |
if (years > 0) { | |
strTab.push('%@ an'.fmt(years) + ((years > 1) ? 's' : '')); | |
} | |
if (months > 0) { | |
strTab.push('%@ mois'.fmt(months)); | |
} | |
if (days > 0) { | |
strTab.push('%@ jour'.fmt(days) + ((days > 1) ? 's' : '')); | |
} | |
if (hours > 0) { | |
strTab.push('%@ heure'.fmt(hours) + ((hours > 1) ? 's' : '')); | |
} | |
if (minutes > 0) { | |
strTab.push('%@ minute'.fmt(minutes) + ((minutes > 1) ? 's' : '')); | |
} | |
return strTab.join(', '); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment