Skip to content

Instantly share code, notes, and snippets.

@diefferson
Created November 29, 2018 23:49
Show Gist options
  • Select an option

  • Save diefferson/c9f2ee41c8f67a0990ff61edf5c463c1 to your computer and use it in GitHub Desktop.

Select an option

Save diefferson/c9f2ee41c8f67a0990ff61edf5c463c1 to your computer and use it in GitHub Desktop.
/*
Status dos jogos
aberto - entre 1 e 36 horas
fechando - entre 60 e 15 minutos
nao palpitou - menos de 15 minutos -
fechado - mais que 36 horas de diferença
nao craque - para jogos marcados como craque
*/
fun getStatusGame(game: GameResponse): StatusGame {
val currentDate = Calendar.getInstance().time
if(game.hunch== null){
game.hunch= Hunch()
}
if(game.date != null){
if(game.hunch!!.draw || game.hunch!!.homeWinner || game.hunch!!.awayWinner){
return StatusGame.HUNCHED
}else{
if(currentDate.after(game.date!!.removeMinutes(15))){
return StatusGame.NO_HUNCH
}
if(currentDate.after(game.date!!.removeMinutes(60)) && currentDate.before(game.date!!.removeMinutes(15))){
return StatusGame.CLOSING
}
if(currentDate.after(game.date!!.removeHour(36)) && currentDate.before(game.date!!.removeHour(1))){
return StatusGame.OPEN
}
if(currentDate.before(game.date!!.removeHour(36))){
return StatusGame.CLOSED
}
return StatusGame.NO_HUNCH
}
}
return StatusGame.CLOSED
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment