Skip to content

Commit

Permalink
Refactor #1749
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Jan 10, 2021
1 parent 1c05032 commit a6fbdee
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/components/calendar/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class Calendar extends Component {
hideOnDateTimeSelect: false,
showWeek: false,
locale: null,
dateFormat: 'mm/dd/yy',
dateFormat: null,
panelStyle: null,
panelClassName: null,
monthNavigator: false,
Expand Down Expand Up @@ -294,6 +294,10 @@ export class Calendar extends Component {
});
}

getDateFormat() {
return this.props.dateFormat || localeOption('dateFormat', this.props.locale);
}

onInputFocus(event) {
if (this.ignoreFocusFunctionality) {
this.setState({ focused: true }, () => {
Expand Down Expand Up @@ -2007,7 +2011,7 @@ export class Calendar extends Component {
formattedValue = this.formatTime(date);
}
else {
formattedValue = this.formatDate(date, this.props.dateFormat);
formattedValue = this.formatDate(date, this.getDateFormat());
if(this.props.showTime) {
formattedValue += ' ' + this.formatTime(date);
}
Expand Down Expand Up @@ -2178,11 +2182,11 @@ export class Calendar extends Component {
}
else {
if(this.props.showTime) {
date = this.parseDate(parts[0], this.props.dateFormat);
date = this.parseDate(parts[0], this.getDateFormat());
this.populateTime(date, parts[1], parts[2]);
}
else {
date = this.parseDate(text, this.props.dateFormat);
date = this.parseDate(text, this.getDateFormat());
}
}

Expand Down

0 comments on commit a6fbdee

Please sign in to comment.