We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
moment("2013-04-27T05:48:29.000Z").intervalNow() "3 days 15 hours 2 minutes 53 seconds"
moment("2013-04-27T05:48:29.000Z").intervalNow(1) "in 3 days 15 hours 2 minutes 53 seconds"
need for exact left time without timezone
thank you.
--- moment.orig.js 2013-04-23 23:38:38.945626866 +0900 +++ moment.js 2013-04-23 23:34:49.304488112 +0900 @@ -436,6 +436,7 @@ future : "in %s", past : "%s ago", s : "a few seconds", + ss : "%d seconds", m : "a minute", mm : "%d minutes", h : "an hour", @@ -1163,6 +1164,25 @@ return this.from(moment(), withoutSuffix); }, + interval : function (time, withoutSuffix) { + var i = this.diff(time), + d = moment.duration(Math.abs(i)), + a = d._data, + l = d.lang(), + f = []; + if(a.years) f.push(l.relativeTime(a.years, 0, 'yy')); + if(a.months) f.push(l.relativeTime(a.months, 0, 'MM')); + if(a.days) f.push(l.relativeTime(a.days, 0, 'dd')); + if(a.hours) f.push(l.relativeTime(a.hours, 0, 'hh')); + if(a.minutes) f.push(l.relativeTime(a.minutes, 0, 'mm')); + if(a.seconds) f.push(l.relativeTime(a.seconds, 0, 'ss')); + return withoutSuffix ? l.pastFuture(i, f.join(' ')) : f.join(' '); + }, + + intervalNow : function (withoutSuffix) { + return this.interval(moment(), withoutSuffix); + }, + calendar : function () { var diff = this.diff(moment().startOf('day'), 'days', true), format = diff < -6 ? 'sameElse' :
The text was updated successfully, but these errors were encountered:
That looks interesting. Can you form it as a pull request? I guess it would also need tests, and adding ss to all languages :)
ss
Sorry, something went wrong.
This is a pretty sweet addition, but I think it will have the same issues as outlined in this comment when localizing the string concatenation.
Also, this seems like a better addition to the Duration.prototype than the Moment.prototype.
Duration.prototype
Moment.prototype
Closing in favor of #745
No branches or pull requests
moment("2013-04-27T05:48:29.000Z").intervalNow()
"3 days 15 hours 2 minutes 53 seconds"
moment("2013-04-27T05:48:29.000Z").intervalNow(1)
"in 3 days 15 hours 2 minutes 53 seconds"
need for exact left time without timezone
thank you.
The text was updated successfully, but these errors were encountered: