horarias get
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
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
|
||||
Reference in New Issue
Block a user