diff --git a/angular-moment.js b/angular-moment.js index 146c876..b909541 100644 --- a/angular-moment.js +++ b/angular-moment.js @@ -296,9 +296,10 @@ * with the new locale. Also broadcasts a `amMoment:localeChanged` event on $rootScope. * * @param {string} locale Locale code (e.g. en, es, ru, pt-br, etc.) + * @param {object} values object of locale settings */ - this.changeLocale = function (locale) { - var result = moment.locale(locale); + this.changeLocale = function (locale, values) { + var result = moment.locale(locale, values); if (angular.isDefined(locale)) { $rootScope.$broadcast('amMoment:localeChanged'); diff --git a/tests.js b/tests.js index 4f39210..666c34e 100644 --- a/tests.js +++ b/tests.js @@ -534,6 +534,14 @@ describe('module angularMoment', function () { describe('amMoment service', function () { describe('#changeLocale', function () { + it('should convert today date to custom calendar form', function () { + var today = new Date(); + amMoment.changeLocale('en', {calendar: {sameDay : '[Today]'}}); + var amCalendar = $filter('amCalendar'); + var testDate = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 13, 33, 33); + expect(amCalendar(testDate)).toBe('Today'); + }); + it('should return the current locale', function () { expect(amMoment.changeLocale()).toBe('en'); });