Skip to content
This repository was archived by the owner on Feb 28, 2025. It is now read-only.

Commit 343a731

Browse files
committed
Fix negative time showing minus at the wrong place
1 parent 20a8f59 commit 343a731

File tree

1 file changed

+5
-4
lines changed
  • MicroEngineerProject/MicroEngineer/Utilities

1 file changed

+5
-4
lines changed

MicroEngineerProject/MicroEngineer/Utilities/Utility.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,12 @@ public static TimeParsed ParseSecondsToTimeFormat(double inputSeconds)
6363
return TimeParsed.MinValue();
6464

6565
inputSeconds = Math.Ceiling(inputSeconds);
66+
var absoluteSeconds = Math.Abs(inputSeconds);
6667

67-
int days = (int)(inputSeconds / 21600);
68-
int hours = (int)((inputSeconds - days * 21600) / 3600);
69-
int minutes = (int)((inputSeconds - hours * 3600 - days * 21600) / 60);
70-
int seconds = (int)(inputSeconds - days * 21600 - hours * 3600 - minutes * 60);
68+
int days = (int)(absoluteSeconds / 21600);
69+
int hours = (int)((absoluteSeconds - days * 21600) / 3600);
70+
int minutes = (int)((absoluteSeconds - hours * 3600 - days * 21600) / 60);
71+
int seconds = (int)(absoluteSeconds - days * 21600 - hours * 3600 - minutes * 60);
7172

7273
// If inputSeconds is negative, reverse the sign of the higest calculated value
7374
if (inputSeconds < 0)

0 commit comments

Comments
 (0)