Calendar1.3.0+

  1. // From 2.12.0 onward
  2. moment.updateLocale('en', {
  3. calendar : Object
  4. });
  5. // From 2.8.1 to 2.11.2
  6. moment.locale('en', {
  7. calendar : Object
  8. });
  9. // Deprecated in 2.8.1
  10. moment.lang('en', {
  11. calendar : Object
  12. });

Locale#calendar should have the following formatting strings.

  1. moment.locale('en', {
  2. calendar : {
  3. lastDay : '[Yesterday at] LT',
  4. sameDay : '[Today at] LT',
  5. nextDay : '[Tomorrow at] LT',
  6. lastWeek : '[last] dddd [at] LT',
  7. nextWeek : 'dddd [at] LT',
  8. sameElse : 'L'
  9. }
  10. });

Each of the Locale#calendar keys can also be a callback function with thescope of the current moment and first argument a moment that depicts now. Itshould return a formatting string.

  1. function callback (now) {
  2. return '[hoy a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
  3. }