mirror of
https://github.com/BlackyHawky/Clock.git
synced 2025-07-03 07:23:21 +00:00
Solve the "todo" about sleep time calculation
This commit is contained in:
parent
1144777a10
commit
eb2e18df20
1 changed files with 11 additions and 2 deletions
|
@ -150,13 +150,22 @@ public final class BedtimeFragment extends DeskClockFragment implements
|
|||
mHoursOfSleep = view.findViewById(R.id.hours_of_sleep);
|
||||
|
||||
if (null != alarm) {
|
||||
//TODO: what if someone goes to bed after 12 am
|
||||
int minDiff = alarm.minutes - mSaver.minutes;
|
||||
int hDiff = alarm.hour + 24 - mSaver.hour;
|
||||
int hDiff;
|
||||
|
||||
if (mSaver.hour > alarm.hour || mSaver.hour == alarm.hour && mSaver.minutes > alarm.minutes) {
|
||||
hDiff = alarm.hour + 24 - mSaver.hour;
|
||||
} else if (mSaver.hour == alarm.hour && mSaver.minutes == alarm.minutes) {
|
||||
hDiff = 24;
|
||||
} else {
|
||||
hDiff = alarm.hour - mSaver.hour;
|
||||
}
|
||||
|
||||
if (minDiff < 0) {
|
||||
hDiff = hDiff - 1;
|
||||
minDiff = 60 + minDiff;
|
||||
}
|
||||
|
||||
String diff;
|
||||
if (minDiff == 0) {
|
||||
diff = hDiff + "h";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue