Skip to content

Commit c1baa73

Browse files
committed
feat(tray): If the remaining time exceeds 1 hour, it will now be displayed in hour format instead of minute format.
1 parent 34b0172 commit c1baa73

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/timer.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,17 @@ const char* get_remaining_time_str(TimerContext* ctx) {
4343
}
4444

4545
DWORD remaining = (ctx->endTime - GetTickCount()) / 1000;
46-
int minutes = remaining / 60;
46+
int hours = remaining / 3600;
47+
int minutes = (remaining % 3600) / 60;
4748
int seconds = remaining % 60;
48-
sprintf_s(timeStr, sizeof(timeStr), "KeepAlive - %02d:%02d remaining", minutes, seconds);
49+
if (hours > 0) {
50+
if (minutes > 0) {
51+
sprintf_s(timeStr, sizeof(timeStr), "KeepAlive - %d hours %d minutes remaining", hours, minutes);
52+
} else {
53+
sprintf_s(timeStr, sizeof(timeStr), "KeepAlive - %d hours remaining", hours);
54+
}
55+
} else {
56+
sprintf_s(timeStr, sizeof(timeStr), "KeepAlive - %02d:%02d remaining", minutes, seconds);
57+
}
4958
return timeStr;
5059
}

0 commit comments

Comments
 (0)