forked from MapComplete/MapComplete
Scripts(nsi): stabilize and make scripts more log-friendly
This commit is contained in:
parent
53106cc0bf
commit
2b10c715b0
5 changed files with 71 additions and 25 deletions
21
src/Utils.ts
21
src/Utils.ts
|
@ -127,8 +127,16 @@ In the case that MapComplete is pointed to the testing grounds, the edit will be
|
|||
return str.substring(0, 1).toUpperCase() + str.substring(1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Always prints (at least) digits
|
||||
*
|
||||
* Utils.twoDigits(5) // => "05"
|
||||
* Utils.twoDigits(0) // => "00"
|
||||
* Utils.twoDigits(128) // => "128"
|
||||
* Utils.twoDigits(-5) // => "-5"
|
||||
*/
|
||||
public static twoDigits(i: number) {
|
||||
if (i < 10) {
|
||||
if (i < 10 && i >= 0) {
|
||||
return "0" + i
|
||||
}
|
||||
return "" + i
|
||||
|
@ -1058,7 +1066,16 @@ In the case that MapComplete is pointed to the testing grounds, the edit will be
|
|||
})
|
||||
}
|
||||
|
||||
public static toHumanTime(seconds): string {
|
||||
/**
|
||||
* Converts a number of seconds into a human readable format
|
||||
*
|
||||
* Utils.toHumanTime(45) // => "0:00:45"
|
||||
* Utils.toHumanTime(120) // => "0:02:00"
|
||||
* Utils.toHumanTime(3610) // => "1:00:10"
|
||||
* Utils.toHumanTime(25 * 3600) // => "1days 1h"
|
||||
*
|
||||
*/
|
||||
public static toHumanTime(seconds:number): string {
|
||||
seconds = Math.floor(seconds)
|
||||
let minutes = Math.floor(seconds / 60)
|
||||
seconds = seconds % 60
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue