Skip to content

Commit

Permalink
added zeroPad() function
Browse files Browse the repository at this point in the history
  • Loading branch information
leoncvlt committed Oct 5, 2015
1 parent 3361e80 commit b8bea69
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions flixel/util/FlxStringUtil.hx
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,21 @@ class FlxStringUtil
}
return FlxMath.roundDecimal(Bytes, Precision) + units[curUnit];
}

/**
* Converts an int to string and add leading zeroes to reach a certain number of digits.
*
* @param Number The number to be converted
* @param Digits The amount of digits in the resulting string
* @return The zero-padded string
*/
public static function zeroPad(Number:Int, Digits:Int):String
{
var string:String = "" + Number;
while (string.length < Digits)
string = "0" + string;
return string;
}

/**
* Takes a string and filters out everything but the digits.
Expand Down

0 comments on commit b8bea69

Please sign in to comment.