Skip to content

Commit

Permalink
Fixed #438
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Jun 13, 2018
1 parent 0a6c94d commit 79c8ddf
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/components/calendar/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -817,8 +817,31 @@ export class Calendar extends Component {
}

toggleAMPM(event) {
let date;
if(this.props.value) {
if(this.isSingleSelection())
date = this.props.value;
else
date = this.props.value.length ? this.props.value[0] : this.props.defaultDate||new Date();
}
else {
date = this.props.defaultDate||new Date();
}

this.pm = !this.pm;
this.updateTime(event);

let hour;
if(this.props.hourFormat === '12')
hour = date.getHours() === 0 ? 12 : date.getHours() % 12;
else
hour = date.getHours();

let time = {
hour: hour,
minute: date.getMinutes(),
second: date.getSeconds()
};
this.updateTime(event, time);
event.preventDefault();
}

Expand Down

0 comments on commit 79c8ddf

Please sign in to comment.