I would like to use customized output for calendar in angularMoment.
In momentjs I set it up with:
moment.lang('en', {
calendar : {
lastDay : '[Yesterday at] LT',
sameDay : '[Today at] LT',
nextDay : '[Tomorrow at] LT',
lastWeek : 'ddd, LT',
nextWeek : 'dddd [at] LT',
sameElse : function () {
if (this < moment().startOf('year'))
return 'M/D/YY';
else
return 'ddd, MMM D';
}
}
});
In angular, I tried the following (and a few variations) with no luck:
angular.module('main').constant('angularMomentConfig', {
lang: 'en'
, {
calendar : {
lastDay : '[Yesterday at] LT',
sameDay : '[Today at] LT',
nextDay : '[Tomorrow at] LT',
lastWeek : 'ddd, LT',
nextWeek : 'dddd [at] LT',
sameElse : function () {
if (moment() < moment().startOf('year'))
return 'M/D/YY';
else
return 'ddd, MMM D';
}
}
}
});
Apparently, you don't need to do anything different! I used the
moment.lang
definition without change and it works fine.(Note: use
moment.locale
for more recent versions.)