Files
api/src/controller/horario/get.js
T
2020-10-02 00:47:54 -05:00

29 lines
757 B
JavaScript

const moment = require('moment')
const Horario = require('../../db/tables/Horario')
const get = async () => {
await Horario.findAll()
.then((res) => {
let data = []
let now = moment().add(15, 'minutes')
for (let i = 0; i < res.length; i++) {
let hora = res[i].horario.substr(res[i].horario.indexOf('-') + 1)
let horaNumero = Number(hora.substr(0, hora.indexOf(':')))
let horaLimite = moment()
horaLimite.set('hour', horaNumero)
horaLimite.set('minute', 0)
horaLimite.set('second', 0)
/* Para la noche xd */
// horaLimite.add(1, 'days')
if (now < horaLimite) data.push(res[i])
}
return data
})
.catch((err) => {})
}
module.exports = get