Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
Merge branch 'vosi-patch-1'
Browse files Browse the repository at this point in the history
  • Loading branch information
urish committed Jan 13, 2015
2 parents 9347317 + 4797502 commit 6f06cd7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
5 changes: 3 additions & 2 deletions angular-moment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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} customization object of locale strings to override
*/
this.changeLocale = function (locale) {
var result = moment.locale(locale);
this.changeLocale = function (locale, customization) {
var result = moment.locale(locale, customization);
if (angular.isDefined(locale)) {
$rootScope.$broadcast('amMoment:localeChanged');

Expand Down
2 changes: 1 addition & 1 deletion angular-moment.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion angular-moment.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,14 @@ describe('module angularMoment', function () {

describe('amMoment service', function () {
describe('#changeLocale', function () {
it('should convert today\'s date to custom calendar format', function () {
var today = new Date();
amMoment.changeLocale('en', {calendar: {sameDay : '[This Day]'}});
var amCalendar = $filter('amCalendar');
var testDate = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 13, 33, 33);
expect(amCalendar(testDate)).toBe('This Day');
});

it('should return the current locale', function () {
expect(amMoment.changeLocale()).toBe('en');
});
Expand Down

0 comments on commit 6f06cd7

Please sign in to comment.