Created
October 17, 2011 11:05
-
-
Save hakunin/1292400 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static String getOpenedStatus(List<List<Short>> openingTimes){ | |
| String result = ""; | |
| // TODO: je to koser podminka? | |
| if(openingTimes.size() == 7){ | |
| Calendar cal = Calendar.getInstance(); | |
| int day = cal.get(Calendar.DAY_OF_WEEK) - 1; // takze den nula bude -1, nebo to zacina jednickou? nedele je v cestine 6, mozna bych mel spis pouzit anglicke usporadani.. chce to na to mrknout | |
| Short open = openingTimes.get(day).get(0); | |
| Short close = openingTimes.get(day).get(1); | |
| int hour = (cal.get(Calendar.HOUR_OF_DAY) * 60) + cal.get(Calendar.MINUTE); // toto by se melo spis jmenovat current_minute? | |
| // pokud je otevreno, mrknem, jak dlouho jeste bude | |
| if(hour >= open && hour <= close){ | |
| int howLong = close - hour; // doba do zaviracky v minutach | |
| if(howLong < 60) // dej tu prosim 120, kdz vyjdes z domu a prijdes tam 30 minut pred zavirackou, asi te to moc nepotesi | |
| result = "Otevreno jeste " + howLong + " minut."; | |
| else | |
| result = "Otevreno."; | |
| }else{ // pokud je zavreno, tak to stejne :-) | |
| int howLong = hour - open; // v pripade, ze je 0:05 tak tohle ukaze zaporne cislo a pak se nam pristi podminka podela :) | |
| if(howLong < 60) // znova pouzil bych 120 a dal sem "howLong > 0 && howLong < 60" | |
| result = "Zavreno jeste " + howLong + " minut."; | |
| else | |
| result = "Zavreno."; | |
| } | |
| } | |
| return result; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment