@rbxts/formatting
v1.0.3
Published
Utility functions for formatting numbers and parsing strings back into numbers for Roblox
Downloads
16
Maintainers
Readme
@rbxts/formatting
Utility functions for formatting numbers and parsing strings back into numbers for Roblox
commaFormat
Places commas between every three decimal points in n
Parameters
Examples
commaFormat(1000000) // 1,000,000Returns string
abbreviate
Abbreviates numbers larger than or equal to threshold
Parameters
nnumberthreshold(optional, default100_000)suffixes(optional, defaultbaseSuffixes)
Examples
abbreviate(1000000) // 1M
abbreviate(1000000000000000000000) // 1SxReturns string
parseAbbreviatedNumber
Parses a number formatted by abbreviate() back into a number type
Parameters
suffixedstringsuffixes(optional, defaultbaseSuffixes)
Examples
parseAbbreviatedNumber("1B") // 1000000000Returns number
toSeconds
Takes a remaining time string and converts it to the amount of time it represents in seconds.
Parameters
timestring
Examples
toSeconds("10m 20s") // 620Returns number
toRemainingTime
Takes a time in seconds and converts it to a remaining time string
Parameters
secondsnumbersecondsFormat(optional, default"%ds")minutesFormat(optional, default"%dm")hoursFormat(optional, default"%dh")daysFormat(optional, default"%dd")
Examples
toRemainingTime(310) // 5m 10sReturns string
toLongRemainingTime
Takes a time in seconds and converts it to a long remaining time string
Parameters
secondsnumber
Examples
toLongRemainingTime(3690) // 01:01:30Returns string
