Exemplo n.º 1
0
def getAccidentsBeforeDate(catalog, search_date):
    """
    RETO3 - REQ2
    Llama la función en model que retorna
    el número de accidentes ocurridos anteriores a una fecha.
    """
    search_date = datetime.datetime.strptime(search_date, '%Y-%m-%d')
    return model.getAccidentsBeforeDate(catalog, search_date.date())
def getAccidentsBeforeDate(analyzer, finalDate):
    """
    Retorna los accidentes anteriores a una fecha y la fecha con más accidentes
    """
    finalDate = datetime.datetime.strptime(finalDate, '%Y-%m-%d')
    dataentry, keys = model.getAccidentsBeforeDate(analyzer, finalDate.date())
    num_accidents, fecha = getInfo(dataentry, keys)
    return (num_accidents, fecha)
Exemplo n.º 3
0
def getAccidentsBeforeDate(analyzer, finalDate):
    try:
        finalDate = datetime.datetime.strptime(finalDate, '%Y-%m-%d')
        if om.contains(analyzer['dateIndex'], finalDate.date()) == False:
            return "fecha"
        else:    
            return model.getAccidentsBeforeDate(analyzer,finalDate.date())
    except:
        return "formato"
Exemplo n.º 4
0
def getAccidentsBeforeDate(catalog, search_date):
    """
    Reto3 - Req2
    Llama la función que retorna
    el número de accidentes ocurridos anteriores a una fecha
    """
    search_date = datetime.datetime.strptime(search_date, "%Y-%m-%d")
    year_search_date = str(search_date.year)
    year_bst = catalog[year_search_date]
    return model.getAccidentsBeforeDate(year_bst, search_date.date())
def getAccidentsBeforeDate(analyzer, initialDate):

    try:
        initialDate = datetime.datetime.striptime(initialDate, '%Y-%m-%d') 
        return model.getAccidentsBeforeDate(analyzer, initialDate.date())      
    except:
        return None
        
        
    def getAccidentsByHour(analyzer, maxkey, minkey):
    """
    Llama a la funcion en el model para encontrar los accidentes un una hora especifica.
    """
    return model.getAccidentsByHour(analyzer, maxkey, minkey)
Exemplo n.º 6
0
def getAccidentsBeforeDate(analyzer, date):
    #-------------------
    try:
        separar = date.split("-")
        anio = int(separar[0])
        mes = int(separar[1])
        dia = int(separar[2])
        if dia > 1 and mes > 1:
            dia = dia - 1
        if dia == 1 and mes > 1:
            mes = mes - 1
            dia = 31
        if dia == 1 and mes == 1:
            anio = anio - 1
            mes = 12
            dia = 31
        fecha = str(anio) + "-" + str(mes) + "-" + str(dia)

        newDate1 = datetime.datetime.strptime(fecha, '%Y-%m-%d')
        return model.getAccidentsBeforeDate(newDate1.date(), analyzer)
    except:
        return None
def getAccidentsBeforeDate(analyzer, Date):
    Date = datetime.datetime.strptime(Date, '%Y-%m-%d')
    return model.getAccidentsBeforeDate(analyzer, Date)
def getAccidentsBeforeDate(analyzer, dateinput):
    return model.getAccidentsBeforeDate(analyzer, dateinput)
Exemplo n.º 9
0
def getAccidentsBeforeDate(analyzer, finalDate):
    final = datetime.datetime.strptime(finalDate, '%Y-%m-%d')
    finalDate = final.date()
    model.getAccidentsBeforeDate(analyzer, finalDate)
def getAccidentsBeforeDate(analyzer, finalDate):

    finalDate = datetime.datetime.strptime(finalDate, "%Y-%m-%d")
    return model.getAccidentsBeforeDate(analyzer, finalDate.date())