Browse Source

updating date time picker

master
analuizaff 3 years ago
parent
commit
a4520deb75
  1. 19
      src/app/components/DatePicker.js

19
src/app/components/DatePicker.js

@ -27,12 +27,19 @@ export default function DatePicker(props) {
const validateTimeInput = (selectedDate) => { const validateTimeInput = (selectedDate) => {
const hour = moment(selectedDate, "HH:mm").format("HH:mm"); const hour = moment(selectedDate, "HH:mm").format("HH:mm");
const day_month = moment(date, "DD-MM-YYYY").format("DD-MM-YYYY"); const day_month = moment(date, "DD-MM-YYYY").format("DD-MM-YYYY");
const eventDateTime = moment(
const dateTime = moment(
day_month + "T" + hour, day_month + "T" + hour,
"DD-MM-YYYYTHH:mm" "DD-MM-YYYYTHH:mm"
).format("DD-MM-YYYYTHH:mm");
if (
moment(new Date(), "DD-MM-YYYYTHH:mm").format("DD-MM-YYYYTHH:mm") < eventDateTime) {
).toObject();
var dateTime_event = new Date(
dateTime.years,
dateTime.months,
dateTime.date,
dateTime.hours,
dateTime.minutes
);
var today = new Date();
if (dateTime_event > today) {
Alert.alert("Horário inválido", "Selecione um horário válido", [ Alert.alert("Horário inválido", "Selecione um horário válido", [
{ text: "OK", onPress: () => renderDatePicker() }, { text: "OK", onPress: () => renderDatePicker() },
]); ]);
@ -63,7 +70,9 @@ export default function DatePicker(props) {
setShow(false); setShow(false);
setMode("date"); setMode("date");
} else { } else {
setTime(moment());
//setTime(moment());
setShow(false);
setMode("date");
} }
} }
} }

Loading…
Cancel
Save