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

Commit

Permalink
Merge branch 'patch-1' of https://github.com/vosi/angular-moment into…
Browse files Browse the repository at this point in the history
… vosi-patch-1

Conflicts:
	angular-moment.js

close #102
  • Loading branch information
urish committed Jan 13, 2015
2 parents 9347317 + d80936c commit 88d45fe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions angular-moment.js
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} 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');

Expand Down
8 changes: 8 additions & 0 deletions tests.js
Expand Up @@ -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');
});
Expand Down

0 comments on commit 88d45fe

Please sign in to comment.