Abacus-2.0
From WowAce Wiki
Abacus-2.0 is a library to provide tools for formatting money and time.
Example
local abacus = AceLibrary("Abacus-2.0")
print(abacus:FormatMoneyExtended(10101)) -- "1 Gold 1 Silver 1 Copper"
print(abacus:FormatDurationExtended(98765)) -- "1 Day 3 Hours 26 Mins 05 Secs"
API Documentation
:FormatMoneyExtended(copper [, colorize [, textColor]])
Returns a colored (or not) string showing the amount of gold, silver, and copper
Args
- copper
- number - amount of copper. 100 means 1 silver, 10000 means 1 gold.
- [colorize]
- boolean - Colorizes the text (default: false)
- [textColor]
- boolean - Colorizes the numbers in the text (default: false)
Returns
string - A colored string showing the amount of gold, silver, and copper. It will be in the form of ## Gold ## Silver ## Copper. The numbers will be white (or red if negative) and the labels (Gold, Silver, Copper) will be their associated colors.
Example
assert(abacus:FormatMoneyExtended(10101) == "1 Gold 1 Silver 1 Copper")
:FormatMoneyFull(copper [, colorize [, textColor]])
Returns a colored (or not) string showing the amount of gold, silver, and copper
Args
- copper
- number - amount of copper. 100 means 1 silver, 10000 means 1 gold.
- [colorize]
- boolean - Colorizes the text (default: false)
- [textColor]
- boolean - Colorizes the numbers in the text (default: false)
Returns
string - A colored string showing the amount of gold, silver, and copper. It will be in the form of either ##g ##s ##c, ##s ##c, or ##c. The numbers will be white (or red if negative) and the labels (g, s, and c) will be their associated colors.
Example
assert(abacus:FormatMoneyFull(10101) == "1g 1s 1c")
:FormatMoneyShort(copper [, colorize [, textColor]])
Returns a colored (or not) string showing the amount of money given.
Args
- copper
- number - amount of copper. 100 means 1 silver, 10000 means 1 gold.
- [colorize]
- boolean - Colorizes the text (default: false)
- [textColor]
- boolean - Colorizes the numbers in the text (default: false)
Returns
string - A colored string showing the amount of money given. It will be in the form of either #.#g, #.#s, or #.#c. The numbers will be white (or red if negative) and the labels (g, s, and c) will be their associated colors.
Example
assert(abacus:FormatMoney(10101) == "1.0g")
:FormatMoneyCondensed(copper [, colorize [, textColor]])
- FormatMoneyCondensed(copper [, colorize])
Args
- copper
- number - amount of copper. 100 means 1 silver, 10000 means 1 gold.
- [colorize]
- boolean - Colorizes the text (default: false)
- [textColor]
- boolean - Colorizes the numbers in the text (default: false)
Returns
string - A colored string showing the amount of money given. It will be in the form of either #.##.##, #.##, or #. The numbers will be their associated colors (gold, silver, and copper). If negative, it will show -(#.##.##)
Example
assert(abacus:FormatMoneyShort(10101) == "1.01.01")
:FormatDurationExtended(seconds [, colorize] [, hideSeconds])
Returns a colored (or not) string showing the amount of days, hours, minutes, and seconds.
Args
- seconds
- number - amount of seconds
- [colorize]
- boolean - Colorizes the text. (default: false)
- [hideSeconds]
- boolean - Don't show seconds. (default: false)
Returns
string - a colored string showing the amount of days, hours, minutes, and seconds It will be in the form of ## Days ## Hrs ## Mins ## Secs. The numbers will be white and the labels will be the normal yellow.
Example
assert(abacus:FormatDurationExtended(98765) == "1 Day 3 Hours 26 Mins 05 Secs")
:FormatDurationFull(seconds [, colorize] [, hideSeconds])
Returns a colored (or not) string showing the amount of days, hours, minutes, and seconds.
Args
- seconds
- number - amount of seconds
- [colorize]
- boolean - Colorizes the text. (default: false)
- [hideSeconds]
- boolean - Don't show seconds. (default: false)
Returns
string - A colored string showing the amount of days, hours, minutes, and seconds It will be in the form of either ##d ##h ##m ##s, ##h ##m ##s, ##m ##s, ##s. The numbers will be white and the labels will be the normal yellow.
Example
assert(abacus:FormatDurationFull(98765) == "1d 03h 26m 05s")
:FormatDurationShort(seconds [, colorize] [, hideSeconds])
Returns a colored (or not) string showing the amount of time given.
Args
- seconds
- number - amount of seconds
- [colorize]
- boolean - Colorizes the text. (default: false)
- [hideSeconds]
- boolean - Don't show seconds. (default: false)
Returns
string - A colored (or not) string showing the amount of time given. It will be in the form of either ## days, ## hours, ## mins, or ## secs. The numbers will be white and the labels will be the normal yellow.
Example
assert(abacus:FormatDurationShort(98765) == "27.4 hours")
:FormatDurationCondensed(seconds [, colorize] [, hideSeconds])
Returns a colored (or not) string showing the amount of time given.
Args
- seconds
- number - amount of seconds
- [colorize]
- boolean - Colorizes the text. (default: false)
- [hideSeconds]
- boolean - Don't show seconds. (default: false)
Returns
string - A colored (or not) string showing the amount of time given. It will be in the form of either #:##:##:##, #:##:##, or #:##. The numbers will be white and the labels will be the normal yellow.
Example
assert(abacus:FormatDurationShort(98765) == "1:03:26:05")

