Skip to content

Instantly share code, notes, and snippets.

@user24
Created January 1, 2020 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save user24/206ffc0e3e7be92143b9b037ecfb470d to your computer and use it in GitHub Desktop.
Save user24/206ffc0e3e7be92143b9b037ecfb470d to your computer and use it in GitHub Desktop.
// Returns 'yesterday', 'today', 'tomorrow', or else the full day name
getDayName(mo) {
const daysDifferenceToToday = mo.startOf('day').diff(moment().startOf('day'), 'days');
const differenceMask = {
'-1': 'Yesterday',
0: 'Today',
1: 'Tomorrow'
};
return differenceMask[daysDifferenceToToday] || mo.format('dddd');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment