Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

142
Views
¿Cómo puedo obtener la hora de inicio de la próxima cita de un profesional?

Tengo una lista de citas con una hora de inicio, una hora de finalización y la identificación del practicante.

 const appointments = [ { date: '2022-06-01', start_time: '15:40:00', end_time: '16:10:00', id_professional: 2 }, { date: '2022-06-01', start_time: '16:30:00', end_time: '16:50:00', id_professional: 2 }, { date: '2022-06-01', start_time: '16:30:00', end_time: '16:50:00', id_professional: 3 }, ];

He filtrado las citas que pertenecen a ese profesional, pero ahora lo que quiero hacer es poder obtener la hora de finalización de la primera cita y la hora de inicio de la próxima cita para su posterior procesamiento.

 let timeAux = startTimeInSeconds; professionalIds.forEach(professionalId => { const appointmentsAux = appointments.filter(appointment => { return appointment.id_professional === professionalId; }); appointmentsAux.forEach(appointmentAux => { const startTimeAux = appointmentAux.start_time; const [startTimeAuxHours, startTimeAuxMinutes] = startTimeAux.split(':'); const startTimeAuxInSeconds = (parseInt(startTimeAuxHours) * 60 * 60 + parseInt(startTimeAuxMinutes) * 60); const endTimeAux = appointmentAux.end_time; const [endTimeAuxHours, endTimeAuxMinutes] = endTimeAux.split(':'); const endTimeAuxInSeconds = (parseInt(endTimeAuxHours) * 60 * 60 + parseInt(endTimeAuxMinutes) * 60); if(endTimeAuxInSeconds > startTimeInSeconds){ //appointmen.end_time // We need the following appointment to get its start_time and see if it fits the time. //how do we get the next appointment? if (endTimeAuxInSeconds - startTimeAuxInSeconds > startTimeInSeconds){ //insert cita } } }); });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

forEach() tiene un parámetro de índice que puede usar

 appointmentsAux.forEach((appointmentAux, index) => { const nextAppointment = appointmentsAux[index + 1]; if (nextAppointment) { // do something with the next appointment's info const nextStart = nextAppointment.start_time; } ...
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!