Skip to content

Commit

Permalink
Merge pull request #225 from gpbl/moment-fix
Browse files Browse the repository at this point in the history
moment utilities: make sure weekdays names begin from Sunday
  • Loading branch information
gpbl authored Oct 14, 2016
2 parents 5b9a8c5 + d79bd2f commit 4f7bab0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/addons/MomentLocaleUtils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable import/no-extraneous-dependencies, no-underscore-dangle */

import moment from 'moment';

Expand All @@ -11,11 +11,11 @@ export function formatMonthTitle(date, locale = 'en') {
}

export function formatWeekdayShort(day, locale = 'en') {
return moment().locale(locale).weekday(day).format('dd');
return moment().locale(locale)._locale.weekdaysMin()[day];
}

export function formatWeekdayLong(day, locale = 'en') {
return moment().locale(locale).weekday(day).format('dddd');
return moment().locale(locale)._locale.weekdays()[day];
}

export function getFirstDayOfWeek(locale = 'en') {
Expand Down
4 changes: 2 additions & 2 deletions test/addons/MomentLocaleUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ describe('MomentLocaleUtils', () => {
describe('formatWeekdayShort', () => {
it('should return the short day name as string', () => {
expect(MomentLocaleUtils.formatWeekdayShort(0)).to.equal('Su');
expect(MomentLocaleUtils.formatWeekdayShort(0, 'it')).to.equal('Lu');
expect(MomentLocaleUtils.formatWeekdayShort(0, 'it')).to.equal('Do');
});
});

describe('formatWeekdayLong', () => {
it('should return the long day name as string', () => {
expect(MomentLocaleUtils.formatWeekdayLong(0)).to.equal('Sunday');
expect(MomentLocaleUtils.formatWeekdayLong(0, 'it')).to.equal('Lunedì');
expect(MomentLocaleUtils.formatWeekdayLong(0, 'it')).to.equal('Domenica');
});
});

Expand Down

0 comments on commit 4f7bab0

Please sign in to comment.