Skip to content
This repository was archived by the owner on May 19, 2025. It is now read-only.

Commit a38a339

Browse files
author
Arkadiy Butermanov
authored
Merge pull request #1 from arkadiybutermanov/add-locale-prop
Add locale property
2 parents d5ebc00 + a00209a commit a38a339

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

lib/Calendar.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ var Calendar = (function (_Component) {
6969
var theme = props.theme;
7070
var offset = props.offset;
7171
var firstDayOfWeek = props.firstDayOfWeek;
72+
var locale = props.locale;
73+
74+
if (locale) {
75+
_moment2['default'].locale(locale);
76+
}
7277

7378
var date = (0, _utilsParseInputJs2['default'])(props.date, format);
7479
var state = {
@@ -346,7 +351,8 @@ Calendar.propTypes = {
346351
linkCB: _react.PropTypes.func,
347352
theme: _react.PropTypes.object,
348353
onlyClasses: _react.PropTypes.bool,
349-
classNames: _react.PropTypes.object
354+
classNames: _react.PropTypes.object,
355+
locale: _react.PropTypes.string
350356
};
351357

352358
exports['default'] = Calendar;

lib/utils/parseInput.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ function parseInput(input, format) {
2121
} else if (typeof input === 'function') {
2222
output = parseInput(input((0, _moment2['default'])().startOf('day')), format);
2323
} else if (input._isAMomentObject) {
24-
output = input.clone().startOf('day');
24+
output = input.startOf('day').clone();
2525
}
2626

2727
return output;
2828
}
2929

30-
module.exports = exports['default'];
30+
module.exports = exports['default'];

src/Calendar.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ class Calendar extends Component {
3535
constructor(props, context) {
3636
super(props, context);
3737

38-
const { format, range, theme, offset, firstDayOfWeek } = props;
38+
const { format, range, theme, offset, firstDayOfWeek, locale } = props;
39+
40+
if(locale) {
41+
moment.locale(locale);
42+
}
3943

4044
const date = parseInput(props.date, format)
4145
const state = {
@@ -251,7 +255,8 @@ Calendar.propTypes = {
251255
linkCB : PropTypes.func,
252256
theme : PropTypes.object,
253257
onlyClasses : PropTypes.bool,
254-
classNames : PropTypes.object
258+
classNames : PropTypes.object,
259+
locale : PropTypes.string
255260
}
256261

257262
export default Calendar;

0 commit comments

Comments
 (0)