Browse Source

fixing a datetime picker issue

master
analuizaff 3 years ago
parent
commit
c30422c09f
  1. 10
      src/app/components/DatePicker.js

10
src/app/components/DatePicker.js

@ -25,9 +25,15 @@ export default function DatePicker(props) {
const [time, setTime] = useState(moment(defaultDate));
const validateTimeInput = (selectedDate) => {
const hour = moment(selectedDate, "HH:mm").format("HH:mm");
const day_month = moment(date, "DD-MM-YYYY").format("DD-MM-YYYY");
const eventDateTime = moment(
day_month + "T" + hour,
"DD-MM-YYYYTHH:mm"
).format("DD-MM-YYYYTHH:mm");
if (
!moment().isSameOrAfter(selectedDate) &&
new Date(moment()).getDay() == new Date(date).getDay()
moment(new Date(), "DD-MM-YYYYTHH:mm").format("DD-MM-YYYYTHH:mm") <
eventDateTime
) {
Alert.alert("Horário inválido", "Selecione um horário válido", [
{ text: "OK", onPress: () => renderDatePicker() },

Loading…
Cancel
Save