mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-18 20:25:45 +01:00
fix negative time display (#153)
This commit is contained in:
parent
df70458e4f
commit
d7193ca8ff
@ -1737,13 +1737,11 @@ const base: InternalAPI<NS> = {
|
||||
|
||||
return numeralWrapper.format(n, format);
|
||||
},
|
||||
tFormat:
|
||||
(ctx) =>
|
||||
(_milliseconds, _milliPrecision = false) => {
|
||||
const milliseconds = helpers.number(ctx, "milliseconds", _milliseconds);
|
||||
const milliPrecision = !!_milliPrecision;
|
||||
return convertTimeMsToTimeElapsedString(milliseconds, milliPrecision);
|
||||
},
|
||||
tFormat: (ctx) => (_milliseconds, _milliPrecision) => {
|
||||
const milliseconds = helpers.number(ctx, "milliseconds", _milliseconds);
|
||||
const milliPrecision = !!_milliPrecision;
|
||||
return convertTimeMsToTimeElapsedString(milliseconds, milliPrecision);
|
||||
},
|
||||
getTimeSinceLastAug: () => () => {
|
||||
return Player.playtimeSinceLastAug;
|
||||
},
|
||||
|
@ -7,7 +7,8 @@ e.g. 10000 -> "10 seconds"
|
||||
120000 -> "2 minutes and 0 seconds"
|
||||
*/
|
||||
function convertTimeMsToTimeElapsedString(time: number, showMilli = false): string {
|
||||
time = Math.floor(time);
|
||||
const negFlag = time < 0;
|
||||
time = Math.abs(Math.floor(time));
|
||||
const millisecondsPerSecond = 1000;
|
||||
const secondPerMinute = 60;
|
||||
const minutesPerHours = 60;
|
||||
@ -47,7 +48,7 @@ function convertTimeMsToTimeElapsedString(time: number, showMilli = false): stri
|
||||
}
|
||||
res += `${seconds} second${!showMilli && secTruncMinutes === 1 ? "" : "s"}`;
|
||||
|
||||
return res;
|
||||
return negFlag ? `-(${res})` : res;
|
||||
}
|
||||
|
||||
// Finds the longest common starting substring in a set of strings
|
||||
|
Loading…
Reference in New Issue
Block a user