Skip to content

Instantly share code, notes, and snippets.

@timrwood
Created November 8, 2012 22:55
Show Gist options
  • Save timrwood/4042410 to your computer and use it in GitHub Desktop.
Save timrwood/4042410 to your computer and use it in GitHub Desktop.
Combining calendar and from
moment.fn.fromTodayCalendarElse = function () {
var isSameDay = +this.clone().startOf('day') === +moment().startOf('day');
if (isSameDay) {
return this.fromNow();
} else {
return this.calendar();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment