Skip to content

Instantly share code, notes, and snippets.

@marcomontes
Created June 11, 2015 14:23
Show Gist options
  • Save marcomontes/2e7a86f4e4949a5cd063 to your computer and use it in GitHub Desktop.
Save marcomontes/2e7a86f4e4949a5cd063 to your computer and use it in GitHub Desktop.
Sistema parqueadero - calculo de tiempo
def calculo_tiempo(tiempo = "hora")
if tiempo == "hora"
segundos = self.fecha_salida - self.fecha_entrada
horas = (segundos / 3600)
if self.fecha_salida.hour < self.fecha_entrada.hour
total_horas = 24 - self.fecha_entrada.hour + self.fecha_salida.hour
else
total_horas = horas
end
total_horas.round(2).ceil
else
1
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment