Skip to content

Instantly share code, notes, and snippets.

@mctep
Created June 20, 2013 12:12
Show Gist options
  • Select an option

  • Save mctep/5822230 to your computer and use it in GitHub Desktop.

Select an option

Save mctep/5822230 to your computer and use it in GitHub Desktop.
Draft time left counter. Return how much time had left from timestamp.
timec.i18n('en-US', function(frame, value) {
var plural = !(value[value.length - 1] == 1);
switch frame {
case this.DAY: {
return plural
? 'days'
: 'day'
} break;
case this.MONTH: {
return plural
? 'months'
: 'month'
}
case this.WEEK: {
return plural
? 'weeks'
: 'week'
}
/* ... */
}
});
timec(timestamp, 'Left %months, %weeks and %days')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment