vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | Name: Abacus-2.0 |
||
3 | Revision: $Rev: 8879 $ |
||
4 | Author(s): ckknight (ckknight@gmail.com) |
||
5 | Website: http://ckknight.wowinterface.com/ |
||
6 | Documentation: http://wiki.wowace.com/index.php/Abacus-2.0 |
||
7 | SVN: http://svn.wowace.com/root/trunk/AbacusLib/Abacus-2.0 |
||
8 | Description: A library to provide tools for formatting money and time. |
||
9 | Dependencies: AceLibrary |
||
10 | ]] |
||
11 | |||
12 | local MAJOR_VERSION = "Abacus-2.0" |
||
13 | local MINOR_VERSION = "$Revision: 8879 $" |
||
14 | |||
15 | if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary") end |
||
16 | if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end |
||
17 | |||
18 | local Abacus = {} |
||
19 | |||
20 | local COPPER_ABBR = string.lower(string.sub(COPPER, 1, 1)) |
||
21 | local SILVER_ABBR = string.lower(string.sub(SILVER, 1, 1)) |
||
22 | local GOLD_ABBR = string.lower(string.sub(GOLD, 1, 1)) |
||
23 | if string.byte(COPPER_ABBR) > 127 then |
||
24 | -- non-western |
||
25 | COPPER_ABBR = COPPER |
||
26 | SILVER_ABBR = SILVER |
||
27 | GOLD_ABBR = GOLD |
||
28 | end |
||
29 | |||
30 | local COLOR_WHITE = "ffffff" |
||
31 | local COLOR_GREEN = "00ff00" |
||
32 | local COLOR_RED = "ff0000" |
||
33 | local COLOR_COPPER = "eda55f" |
||
34 | local COLOR_SILVER = "c7c7cf" |
||
35 | local COLOR_GOLD = "ffd700" |
||
36 | |||
37 | local L_DAY_ONELETTER_ABBR = string.sub(DAY_ONELETTER_ABBR, 4) |
||
38 | local L_HOUR_ONELETTER_ABBR = string.sub(HOUR_ONELETTER_ABBR, 4) |
||
39 | local L_MINUTE_ONELETTER_ABBR = string.sub(MINUTE_ONELETTER_ABBR, 4) |
||
40 | local L_SECOND_ONELETTER_ABBR = string.sub(SECOND_ONELETTER_ABBR, 4) |
||
41 | |||
42 | local inf = 1/0 |
||
43 | |||
44 | function Abacus:FormatMoneyExtended(value, colorize, textColor) |
||
45 | self:argCheck(value, 2, "number") |
||
46 | local gold = value / 10000 |
||
47 | local silver = abs(mod(value / 100, 100)) |
||
48 | local copper = abs(mod(value, 100)) |
||
49 | |||
50 | local color = COLOR_WHITE |
||
51 | if textColor then |
||
52 | if value > 0 then |
||
53 | color = COLOR_GREEN |
||
54 | elseif value < 0 then |
||
55 | color = COLOR_RED |
||
56 | end |
||
57 | end |
||
58 | if colorize then |
||
59 | if value == inf or value == -inf then |
||
60 | return format("|cff%s%s|r", color, value) |
||
61 | elseif value ~= value then |
||
62 | return format("|cff%s0|r|cff%s %s|r", COLOR_WHITE, COLOR_COPPER, COPPER) |
||
63 | elseif value >= 10000 or value <= -10000 then |
||
64 | return format("|cff%s%d|r|cff%s %s|r |cff%s%d|r|cff%s %s|r |cff%s%d|r|cff%s %s|r", color, gold, COLOR_GOLD, GOLD, color, silver, COLOR_SILVER, SILVER, color, copper, COLOR_COPPER, COPPER) |
||
65 | elseif value >= 100 or value <= -100 then |
||
66 | return format("|cff%s%d|r|cff%s %s|r |cff%s%d|r|cff%s %s|r", color, silver, COLOR_SILVER, SILVER, color, copper, COLOR_COPPER, COPPER) |
||
67 | else |
||
68 | return format("|cff%s%d|r|cff%s %s|r", color, copper, COLOR_COPPER, COPPER) |
||
69 | end |
||
70 | else |
||
71 | if value == inf or value == -inf then |
||
72 | return format("%s", value) |
||
73 | elseif value ~= value then |
||
74 | return format("0 %s", COPPER) |
||
75 | elseif value >= 10000 or value <= -10000 then |
||
76 | return format("%d %s %d %s %d %s", gold, GOLD, silver, SILVER, copper, COPPER) |
||
77 | elseif value >= 100 or value <= -100 then |
||
78 | return format("%d %s %d %s", silver, SILVER, copper, COPPER) |
||
79 | else |
||
80 | return format("%d %s", copper, COPPER) |
||
81 | end |
||
82 | end |
||
83 | end |
||
84 | |||
85 | function Abacus:FormatMoneyFull(value, colorize, textColor) |
||
86 | self:argCheck(value, 2, "number") |
||
87 | local gold = value / 10000 |
||
88 | local silver = abs(mod(value / 100, 100)) |
||
89 | local copper = abs(mod(value, 100)) |
||
90 | |||
91 | local color = COLOR_WHITE |
||
92 | if textColor then |
||
93 | if value > 0 then |
||
94 | color = COLOR_GREEN |
||
95 | elseif value < 0 then |
||
96 | color = COLOR_RED |
||
97 | end |
||
98 | end |
||
99 | if colorize then |
||
100 | if value == inf or value == -inf then |
||
101 | return format("|cff%s%s|r", color, value) |
||
102 | elseif value ~= value then |
||
103 | return format("|cff%s0|r|cff%s%s|r", COLOR_WHITE, COLOR_COPPER, COPPER_ABBR) |
||
104 | elseif value >= 10000 or value <= -10000 then |
||
105 | return format("|cff%s%d|r|cff%s%s|r |cff%s%d|r|cff%s%s|r |cff%s%d|r|cff%s%s|r", color, gold, COLOR_GOLD, GOLD_ABBR, color, silver, COLOR_SILVER, SILVER_ABBR, color, copper, COLOR_COPPER, COPPER_ABBR) |
||
106 | elseif value >= 100 or value <= -100 then |
||
107 | return format("|cff%s%d|r|cff%s%s|r |cff%s%d|r|cff%s%s|r", color, silver, COLOR_SILVER, SILVER_ABBR, color, copper, COLOR_COPPER, COPPER_ABBR) |
||
108 | else |
||
109 | return format("|cff%s%d|r|cff%s%s|r", color, copper, COLOR_COPPER, COPPER_ABBR) |
||
110 | end |
||
111 | else |
||
112 | if value == inf or value == -inf then |
||
113 | return format("%s", value) |
||
114 | elseif value ~= value then |
||
115 | return format("0%s", COPPER_ABBR) |
||
116 | elseif value >= 10000 or value <= -10000 then |
||
117 | return format("%d%s %d%s %d%s", gold, GOLD_ABBR, silver, SILVER_ABBR, copper, COPPER_ABBR) |
||
118 | elseif value >= 100 or value <= -100 then |
||
119 | return format("%d%s %d%s", silver, SILVER_ABBR, copper, COPPER_ABBR) |
||
120 | else |
||
121 | return format("%d%s", copper, COPPER_ABBR) |
||
122 | end |
||
123 | end |
||
124 | end |
||
125 | |||
126 | function Abacus:FormatMoneyShort(copper, colorize, textColor) |
||
127 | self:argCheck(copper, 2, "number") |
||
128 | local color = COLOR_WHITE |
||
129 | if textColor then |
||
130 | if copper > 0 then |
||
131 | color = COLOR_GREEN |
||
132 | elseif copper < 0 then |
||
133 | color = COLOR_RED |
||
134 | end |
||
135 | end |
||
136 | if colorize then |
||
137 | if value == inf or value == -inf then |
||
138 | return format("|cff%s%s|r", color, value) |
||
139 | elseif value ~= value then |
||
140 | return format("|cff%s0|r|cff%s%s|r", COLOR_WHITE, COLOR_COPPER, COPPER_ABBR) |
||
141 | elseif copper >= 10000 or copper <= -10000 then |
||
142 | return format("|cff%s%.1f|r|cff%s%s|r", color, copper / 10000, COLOR_GOLD, GOLD_ABBR) |
||
143 | elseif copper >= 100 or copper <= -100 then |
||
144 | return format("|cff%s%.1f|r|cff%s%s|r", color, copper / 100, COLOR_SILVER, SILVER_ABBR) |
||
145 | else |
||
146 | return format("|cff%s%d|r|cff%s%s|r", color, copper, COLOR_COPPER, COPPER_ABBR) |
||
147 | end |
||
148 | else |
||
149 | if value == inf or value == -inf then |
||
150 | return format("%s", value) |
||
151 | elseif value ~= value then |
||
152 | return format("0%s", COPPER_ABBR) |
||
153 | elseif copper >= 10000 or copper <= -10000 then |
||
154 | return format("%.1f%s", copper / 10000, GOLD_ABBR) |
||
155 | elseif copper >= 100 or copper <= -100 then |
||
156 | return format("%.1f%s", copper / 100, SILVER_ABBR) |
||
157 | else |
||
158 | return format("%.0f%s", copper, COPPER_ABBR) |
||
159 | end |
||
160 | end |
||
161 | end |
||
162 | |||
163 | function Abacus:FormatMoneyCondensed(value, colorize, textColor) |
||
164 | self:argCheck(value, 2, "number") |
||
165 | local negl = value < 0 and "(-" or "" |
||
166 | local negr = value < 0 and ")" or "" |
||
167 | if value < 0 then |
||
168 | if colorize and textColor then |
||
169 | negl = "|cffff0000-(|r" |
||
170 | negr = "|cffff0000)|r" |
||
171 | else |
||
172 | negl = "-(" |
||
173 | negr = ")" |
||
174 | end |
||
175 | else |
||
176 | negl = "" |
||
177 | negr = "" |
||
178 | end |
||
179 | local gold = floor(math.abs(value) / 10000) |
||
180 | local silver = mod(floor(math.abs(value) / 100), 100) |
||
181 | local copper = mod(floor(math.abs(value)), 100) |
||
182 | if colorize then |
||
183 | if value == inf or value == -inf then |
||
184 | return format("%s|cff%s%s|r%s", negl, COLOR_COPPER, math.abs(value), negr) |
||
185 | elseif value ~= value then |
||
186 | return format("|cff%s0|r", COLOR_COPPER) |
||
187 | elseif gold ~= 0 then |
||
188 | return format("%s|cff%s%d|r.|cff%s%02d|r.|cff%s%02d|r%s", negl, COLOR_GOLD, gold, COLOR_SILVER, silver, COLOR_COPPER, copper, negr) |
||
189 | elseif silver ~= 0 then |
||
190 | return format("%s|cff%s%d|r.|cff%s%02d|r%s", negl, COLOR_SILVER, silver, COLOR_COPPER, copper, negr) |
||
191 | else |
||
192 | return format("%s|cff%s%d|r%s", negl, COLOR_COPPER, copper, negr) |
||
193 | end |
||
194 | else |
||
195 | if value == inf or value == -inf then |
||
196 | return tostring(value) |
||
197 | elseif value ~= value then |
||
198 | return "0" |
||
199 | elseif gold ~= 0 then |
||
200 | return format("%s%d.%02d.%02d%s", negl, gold, silver, copper, negr) |
||
201 | elseif silver ~= 0 then |
||
202 | return format("%s%d.%02d%s", negl, silver, copper, negr) |
||
203 | else |
||
204 | return format("%s%d%s", negl, copper, negr) |
||
205 | end |
||
206 | end |
||
207 | end |
||
208 | |||
209 | local t |
||
210 | function Abacus:FormatDurationExtended(duration, colorize, hideSeconds) |
||
211 | self:argCheck(duration, 2, "number") |
||
212 | local negative = "" |
||
213 | if duration ~= duration then |
||
214 | duration = 0 |
||
215 | end |
||
216 | if duration < 0 then |
||
217 | negative = "-" |
||
218 | duration = -duration |
||
219 | end |
||
220 | local days = floor(duration / 86400) |
||
221 | local hours = mod(floor(duration / 3600), 24) |
||
222 | local mins = mod(floor(duration / 60), 60) |
||
223 | local secs = mod(floor(duration), 60) |
||
224 | if not t then |
||
225 | t = {} |
||
226 | else |
||
227 | for k in pairs(t) do |
||
228 | t[k] = nil |
||
229 | end |
||
230 | table.setn(t, 0) |
||
231 | end |
||
232 | if not colorize then |
||
233 | if not duration or duration > 86400*365 then |
||
234 | return "Undetermined" |
||
235 | end |
||
236 | if days > 1 then |
||
237 | table.insert(t, format("%d %s", days, DAYS_ABBR_P1)) |
||
238 | elseif days == 1 then |
||
239 | table.insert(t, format("%d %s", days, DAYS_ABBR)) |
||
240 | end |
||
241 | if hours > 1 then |
||
242 | table.insert(t, format("%d %s", hours, HOURS_ABBR_P1)) |
||
243 | elseif hours == 1 then |
||
244 | table.insert(t, format("%d %s", hours, HOURS_ABBR)) |
||
245 | end |
||
246 | if mins > 1 then |
||
247 | table.insert(t, format("%d %s", mins, MINUTES_ABBR_P1)) |
||
248 | elseif mins == 1 then |
||
249 | table.insert(t, format("%d %s", mins, MINUTES_ABBR)) |
||
250 | end |
||
251 | if not hideSeconds then |
||
252 | if secs > 1 then |
||
253 | table.insert(t, format("%d %s", secs, SECONDS_ABBR_P1)) |
||
254 | elseif secs == 1 then |
||
255 | table.insert(t, format("%d %s", secs, SECONDS_ABBR)) |
||
256 | end |
||
257 | end |
||
258 | if table.getn(t) == 0 then |
||
259 | if not hideSeconds then |
||
260 | return "0 " .. SECONDS_ABBR_P1 |
||
261 | else |
||
262 | return "0 " .. MINUTES_ABBR_P1 |
||
263 | end |
||
264 | else |
||
265 | return negative .. table.concat(t, " ") |
||
266 | end |
||
267 | else |
||
268 | if not duration or duration > 86400*365 then |
||
269 | return "|cffffffffUndetermined|r" |
||
270 | end |
||
271 | if days > 1 then |
||
272 | table.insert(t, format("|cffffffff%d|r %s", days, DAYS_ABBR_P1)) |
||
273 | elseif days == 1 then |
||
274 | table.insert(t, format("|cffffffff%d|r %s", days, DAYS_ABBR)) |
||
275 | end |
||
276 | if hours > 1 then |
||
277 | table.insert(t, format("|cffffffff%d|r %s", hours, HOURS_ABBR_P1)) |
||
278 | elseif hours == 1 then |
||
279 | table.insert(t, format("|cffffffff%d|r %s", hours, HOURS_ABBR)) |
||
280 | end |
||
281 | if mins > 1 then |
||
282 | table.insert(t, format("|cffffffff%d|r %s", mins, MINUTES_ABBR_P1)) |
||
283 | elseif mins == 1 then |
||
284 | table.insert(t, format("|cffffffff%d|r %s", mins, MINUTES_ABBR)) |
||
285 | end |
||
286 | if not hideSeconds then |
||
287 | if secs > 1 then |
||
288 | table.insert(t, format("|cffffffff%d|r %s", secs, SECONDS_ABBR_P1)) |
||
289 | elseif secs == 1 then |
||
290 | table.insert(t, format("|cffffffff%d|r %s", secs, SECONDS_ABBR)) |
||
291 | end |
||
292 | end |
||
293 | if table.getn(t) == 0 then |
||
294 | if not hideSeconds then |
||
295 | return "|cffffffff0|r " .. SECONDS_ABBR_P1 |
||
296 | else |
||
297 | return "|cffffffff0|r " .. MINUTES_ABBR_P1 |
||
298 | end |
||
299 | elseif negative == "-" then |
||
300 | return "|cffffffff-|r" .. table.concat(t, " ") |
||
301 | else |
||
302 | return table.concat(t, " ") |
||
303 | end |
||
304 | end |
||
305 | end |
||
306 | |||
307 | local DAY_ONELETTER_ABBR = string.gsub(DAY_ONELETTER_ABBR, "%s*%%d%s*", "") |
||
308 | local HOUR_ONELETTER_ABBR = string.gsub(HOUR_ONELETTER_ABBR, "%s*%%d%s*", "") |
||
309 | local MINUTE_ONELETTER_ABBR = string.gsub(MINUTE_ONELETTER_ABBR, "%s*%%d%s*", "") |
||
310 | local SECOND_ONELETTER_ABBR = string.gsub(SECOND_ONELETTER_ABBR, "%s*%%d%s*", "") |
||
311 | |||
312 | function Abacus:FormatDurationFull(duration, colorize, hideSeconds) |
||
313 | self:argCheck(duration, 2, "number") |
||
314 | local negative = "" |
||
315 | if duration ~= duration then |
||
316 | duration = 0 |
||
317 | end |
||
318 | if duration < 0 then |
||
319 | negative = "-" |
||
320 | duration = -duration |
||
321 | end |
||
322 | if not colorize then |
||
323 | if not hideSeconds then |
||
324 | if not duration or duration > 86400*365 then |
||
325 | return "Undetermined" |
||
326 | elseif duration >= 86400 then |
||
327 | return format("%s%d%s %02d%s %02d%s %02d%s", negative, duration/86400, L_DAY_ONELETTER_ABBR, mod(duration/3600, 24), L_HOUR_ONELETTER_ABBR, mod(duration/60, 60), L_MINUTE_ONELETTER_ABBR, mod(duration, 60), L_SECOND_ONELETTER_ABBR) |
||
328 | elseif duration >= 3600 then |
||
329 | return format("%s%d%s %02d%s %02d%s", negative, duration/3600, L_HOUR_ONELETTER_ABBR, mod(duration/60, 60), L_MINUTE_ONELETTER_ABBR, mod(duration, 60), L_SECOND_ONELETTER_ABBR) |
||
330 | elseif duration >= 120 then |
||
331 | return format("%s%d%s %02d%s", negative, duration/60, L_MINUTE_ONELETTER_ABBR, mod(duration, 60), L_SECOND_ONELETTER_ABBR) |
||
332 | else |
||
333 | return format("%s%d%s", negative, duration, L_SECOND_ONELETTER_ABBR) |
||
334 | end |
||
335 | else |
||
336 | if not duration or duration > 86400*365 then |
||
337 | return "Undetermined" |
||
338 | elseif duration >= 86400 then |
||
339 | return format("%s%d%s %02d%s %02d%s", negative, duration/86400, L_DAY_ONELETTER_ABBR, mod(duration/3600, 24), L_HOUR_ONELETTER_ABBR, mod(duration/60, 60), L_MINUTE_ONELETTER_ABBR) |
||
340 | elseif duration >= 3600 then |
||
341 | return format("%s%d%s %02d%s", negative, duration/3600, L_HOUR_ONELETTER_ABBR, mod(duration/60, 60), L_MINUTE_ONELETTER_ABBR) |
||
342 | else |
||
343 | return format("%s%d%s", negative, duration/60, L_MINUTE_ONELETTER_ABBR) |
||
344 | end |
||
345 | end |
||
346 | else |
||
347 | if not hideSeconds then |
||
348 | if not duration or duration > 86400*365 then |
||
349 | return "|cffffffffUndetermined|r" |
||
350 | elseif duration >= 86400 then |
||
351 | return format("|cffffffff%s%d|r%s |cffffffff%02d|r%s |cffffffff%02d|r%s |cffffffff%02d|r%s", negative, duration/86400, L_DAY_ONELETTER_ABBR, mod(duration/3600, 24), L_HOUR_ONELETTER_ABBR, mod(duration/60, 60), L_MINUTE_ONELETTER_ABBR, mod(duration, 60), L_SECOND_ONELETTER_ABBR) |
||
352 | elseif duration >= 3600 then |
||
353 | return format("|cffffffff%s%d|r%s |cffffffff%02d|r%s |cffffffff%02d|r%s", negative, duration/3600, L_HOUR_ONELETTER_ABBR, mod(duration/60, 60), L_MINUTE_ONELETTER_ABBR, mod(duration, 60), L_SECOND_ONELETTER_ABBR) |
||
354 | elseif duration >= 120 then |
||
355 | return format("|cffffffff%s%d|r%s |cffffffff%02d|r%s", negative, duration/60, L_MINUTE_ONELETTER_ABBR, mod(duration, 60), L_SECOND_ONELETTER_ABBR) |
||
356 | else |
||
357 | return format("|cffffffff%s%d|r%s", negative, duration, L_SECOND_ONELETTER_ABBR) |
||
358 | end |
||
359 | else |
||
360 | if not duration or duration > 86400*365 then |
||
361 | return "|cffffffffUndetermined|r" |
||
362 | elseif duration >= 86400 then |
||
363 | return format("|cffffffff%s%d|r%s |cffffffff%02d|r%s |cffffffff%02d|r%s", negative, duration/86400, L_DAY_ONELETTER_ABBR, mod(duration/3600, 24), L_HOUR_ONELETTER_ABBR, mod(duration/60, 60), L_MINUTE_ONELETTER_ABBR) |
||
364 | elseif duration >= 3600 then |
||
365 | return format("|cffffffff%s%d|r%s |cffffffff%02d|r%s", negative, duration/3600, L_HOUR_ONELETTER_ABBR, mod(duration/60, 60), L_MINUTE_ONELETTER_ABBR) |
||
366 | else |
||
367 | return format("|cffffffff%s%d|r%s", negative, duration/60, L_MINUTE_ONELETTER_ABBR) |
||
368 | end |
||
369 | end |
||
370 | end |
||
371 | end |
||
372 | |||
373 | function Abacus:FormatDurationShort(duration, colorize, hideSeconds) |
||
374 | self:argCheck(duration, 2, "number") |
||
375 | local negative = "" |
||
376 | if duration ~= duration then |
||
377 | duration = 0 |
||
378 | end |
||
379 | if duration < 0 then |
||
380 | negative = "-" |
||
381 | duration = -duration |
||
382 | end |
||
383 | if not colorize then |
||
384 | if not duration or duration >= 86400*365 then |
||
385 | return "***" |
||
386 | elseif duration >= 172800 then |
||
387 | return format("%s%.1f %s", negative, duration/86400, DAYS_ABBR_P1) |
||
388 | elseif duration >= 7200 then |
||
389 | return format("%s%.1f %s", negative, duration/3600, HOURS_ABBR_P1) |
||
390 | elseif duration >= 120 or not hideSeconds then |
||
391 | return format("%s%.1f %s", negative, duration/60, MINUTES_ABBR_P1) |
||
392 | else |
||
393 | return format("%s%.0f %s", negative, duration, SECONDS_ABBR_P1) |
||
394 | end |
||
395 | else |
||
396 | if not duration or duration >= 86400*365 then |
||
397 | return "|cffffffff***|r" |
||
398 | elseif duration >= 172800 then |
||
399 | return format("|cffffffff%s%.1f|r %s", negative, duration/86400, DAYS_ABBR_P1) |
||
400 | elseif duration >= 7200 then |
||
401 | return format("|cffffffff%s%.1f|r %s", negative, duration/3600, HOURS_ABBR_P1) |
||
402 | elseif duration >= 120 or not hideSeconds then |
||
403 | return format("|cffffffff%s%.1f|r %s", negative, duration/60, MINUTES_ABBR_P1) |
||
404 | else |
||
405 | return format("|cffffffff%s%.0f|r %s", negative, duration, SECONDS_ABBR_P1) |
||
406 | end |
||
407 | end |
||
408 | end |
||
409 | |||
410 | function Abacus:FormatDurationCondensed(duration, colorize, hideSeconds) |
||
411 | self:argCheck(duration, 2, "number") |
||
412 | local negative = "" |
||
413 | if duration ~= duration then |
||
414 | duration = 0 |
||
415 | end |
||
416 | if duration < 0 then |
||
417 | negative = "-" |
||
418 | duration = -duration |
||
419 | end |
||
420 | if not colorize then |
||
421 | if hideSeconds then |
||
422 | if not duration or duration >= 86400*365 then |
||
423 | return format("%s**%s **:**", negative, L_DAY_ONELETTER_ABBR) |
||
424 | elseif duration >= 86400 then |
||
425 | return format("%s%d%s %d:%02d", negative, duration/86400, L_DAY_ONELETTER_ABBR, mod(duration/3600, 24), mod(duration/60, 60)) |
||
426 | else |
||
427 | return format("%s%d:%02d", negative, duration/3600, mod(duration/60, 60)) |
||
428 | end |
||
429 | else |
||
430 | if not duration or duration >= 86400*365 then |
||
431 | return negative .. "**:**:**:**" |
||
432 | elseif duration >= 86400 then |
||
433 | return format("%s%d%s %d:%02d:%02d", negative, duration/86400, L_DAY_ONELETTER_ABBR, mod(duration/3600, 24), mod(duration/60, 60), mod(duration, 60)) |
||
434 | elseif duration >= 3600 then |
||
435 | return format("%s%d:%02d:%02d", negative, duration/3600, mod(duration/60, 60), mod(duration, 60)) |
||
436 | else |
||
437 | return format("%s%d:%02d", negative, duration/60, mod(duration, 60)) |
||
438 | end |
||
439 | end |
||
440 | else |
||
441 | if hideSeconds then |
||
442 | if not duration or duration >= 86400*365 then |
||
443 | return format("|cffffffff%s**|r%s |cffffffff**|r:|cffffffff**|r", negative, L_DAY_ONELETTER_ABBR) |
||
444 | elseif duration >= 86400 then |
||
445 | return format("|cffffffff%s%d|r%s |cffffffff%d|r:|cffffffff%02d|r", negative, duration/86400, L_DAY_ONELETTER_ABBR, mod(duration/3600, 24), mod(duration/60, 60)) |
||
446 | else |
||
447 | return format("|cffffffff%s%d|r:|cffffffff%02d|r", negative, duration/3600, mod(duration/60, 60)) |
||
448 | end |
||
449 | else |
||
450 | if not duration or duration >= 86400*365 then |
||
451 | return format("|cffffffff%s**|r%s |cffffffff**|r:|cffffffff**|r:|cffffffff**|r", negative, L_DAY_ONELETTER_ABBR) |
||
452 | elseif duration >= 86400 then |
||
453 | return format("|cffffffff%s%d|r%s |cffffffff%d|r:|cffffffff%02d|r:|cffffffff%02d|r", negative, duration/86400, L_DAY_ONELETTER_ABBR, mod(duration/3600, 24), mod(duration/60, 60), mod(duration, 60)) |
||
454 | elseif duration >= 3600 then |
||
455 | return format("|cffffffff%s%d|r:|cffffffff%02d|r:|cffffffff%02d|r", negative, duration/3600, mod(duration/60, 60), mod(duration, 60)) |
||
456 | else |
||
457 | return format("|cffffffff%s%d|r:|cffffffff%02d|r", negative, duration/60, mod(duration, 60)) |
||
458 | end |
||
459 | end |
||
460 | end |
||
461 | end |
||
462 | |||
463 | AceLibrary:Register(Abacus, MAJOR_VERSION, MINOR_VERSION) |
||
464 | Abacus = nil |