m-date-picker
m-date-picker copied to clipboard
How can we set the time to 12 AM or to 12 PM
Hi i just want to set default time to 12 AM or 12 PM but no luck any help on how to this i'm using the "use12Hours"
Ok i mange to do this but the 12 is not being bolded
my code is
<DatePicker
defaultDate={now}
date={this.state.selectedDateTime}
mode={this.props.mode}
//locale={enUs}
//maxDate={maxDate}
//minDate={minDate}
onDateChange={(date)=>{}}
onValueChange={(vals, index) => {
this._pickerOnValueChange(vals);
}}
formatMonth={((month, date) => {return monthNumToName(month+1) } )}
use12Hours
/>
_pickerOnValueChange = (vals) => {
console.log(vals);
let date = null;
if (this.props.mode === 'date') {
date = new Date(vals[0], vals[1], vals[2], 0, 0, 0);
} else if (this.props.mode === 'time') {
if (vals[2] === "0") {//AM
date = new Date(0, 0, 0, (vals[0] !== "12" ? vals[0] : 0), vals[1], 0);
} else if (vals[2] === "1") { //PM
date = new Date(0, 0, 0, (vals[0] !== "12" ? parseInt(vals[0]) + 12 : 12), vals[1], 0);
}
}
this.setState({selectedDateTime: date});
};
hi you don't have the cols children key 12 and the values are coming ["12", "0", "0"] so the 12 is not bolded if the hours is 12, because the miss match you have in the cols and values
so for now to fix this i added
if (this.props.use12Hours) { if (value[0] === "12") { value[0] = "0"; } }
in the DatePicker.js after line 529 please can you fix this and push