forked from LeenkxTeam/LNXSDK
Repe [T3DU] Update - 31f26d171bba0355ce2a77031e3aad4c64dbc7e9
This commit is contained in:
32
leenkx/Sources/leenkx/logicnode/FormatTimeNode.hx
Normal file
32
leenkx/Sources/leenkx/logicnode/FormatTimeNode.hx
Normal file
@ -0,0 +1,32 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class FormatTimeNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
var time: Float = inputs[0].get();
|
||||
var format: String = inputs[1].get();
|
||||
|
||||
var totalSeconds = Math.floor(time);
|
||||
var milliseconds = Math.floor((time - totalSeconds) * 1000);
|
||||
var centiseconds = Math.floor(milliseconds / 10);
|
||||
|
||||
var h = Math.floor(totalSeconds / 3600);
|
||||
var m = Math.floor((totalSeconds % 3600) / 60);
|
||||
var s = totalSeconds % 60;
|
||||
|
||||
var result = format;
|
||||
result = StringTools.replace(result, "HH", (h < 10 ? "0" : "") + h);
|
||||
result = StringTools.replace(result, "MM", (m < 10 ? "0" : "") + m);
|
||||
result = StringTools.replace(result, "SS", (s < 10 ? "0" : "") + s);
|
||||
result = StringTools.replace(result, "MS", (centiseconds < 10 ? "0" : "") + centiseconds);
|
||||
result = StringTools.replace(result, "H", "" + h);
|
||||
result = StringTools.replace(result, "M", "" + m);
|
||||
result = StringTools.replace(result, "S", "" + s);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user