vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 local MAJOR_VERSION = "1.0"
2 local MINOR_VERSION = tonumber(string.sub("$Revision: 8892 $", 12, -3))
3 if AbacusLib and AbacusLib.versions[MAJOR_VERSION] and AbacusLib.versions[MAJOR_VERSION].minor >= MINOR_VERSION then
4 return
5 end
6  
7 -------------IRIEL'S-STUB-CODE--------------
8 local stub = {};
9  
10 -- Instance replacement method, replace contents of old with that of new
11 function stub:ReplaceInstance(old, new)
12 for k,v in pairs(old) do old[k]=nil; end
13 for k,v in pairs(new) do old[k]=v; end
14 end
15  
16 -- Get a new copy of the stub
17 function stub:NewStub()
18 local newStub = {};
19 self:ReplaceInstance(newStub, self);
20 newStub.lastVersion = '';
21 newStub.versions = {};
22 return newStub;
23 end
24  
25 -- Get instance version
26 function stub:GetInstance(version)
27 if (not version) then version = self.lastVersion; end
28 local versionData = self.versions[version];
29 if (not versionData) then
30 message("Cannot find library instance with version '"
31 .. version .. "'");
32 return;
33 end
34 return versionData.instance;
35 end
36  
37 -- Register new instance
38 function stub:Register(newInstance)
39 local version,minor = newInstance:GetLibraryVersion();
40 self.lastVersion = version;
41 local versionData = self.versions[version];
42 if (not versionData) then
43 -- This one is new!
44 versionData = { instance = newInstance,
45 minor = minor,
46 old = {}
47 };
48 self.versions[version] = versionData;
49 newInstance:LibActivate(self);
50 return newInstance;
51 end
52 if (minor <= versionData.minor) then
53 -- This one is already obsolete
54 if (newInstance.LibDiscard) then
55 newInstance:LibDiscard();
56 end
57 return versionData.instance;
58 end
59 -- This is an update
60 local oldInstance = versionData.instance;
61 local oldList = versionData.old;
62 versionData.instance = newInstance;
63 versionData.minor = minor;
64 local skipCopy = newInstance:LibActivate(self, oldInstance, oldList);
65 table.insert(oldList, oldInstance);
66 if (not skipCopy) then
67 for i, old in ipairs(oldList) do
68 self:ReplaceInstance(old, newInstance);
69 end
70 end
71 return newInstance;
72 end
73  
74 -- Bind stub to global scope if it's not already there
75 if (not AbacusLib) then
76 AbacusLib = stub:NewStub();
77 end
78  
79 -- Nil stub for garbage collection
80 stub = nil;
81 -----------END-IRIEL'S-STUB-CODE------------
82  
83 local function assert(condition, message)
84 if not condition then
85 local stack = debugstack()
86 local first = string.gsub(stack, "\n.*", "")
87 local file = string.gsub(first, "^(.*\\.*).lua:%d+: .*", "%1")
88 file = string.gsub(file, "([%(%)%.%*%+%-%[%]%?%^%$%%])", "%%%1")
89 if not message then
90 local _,_,second = string.find(stack, "\n(.-)\n")
91 message = "assertion failed! " .. second
92 end
93 message = "BabbleLib-Zone: " .. message
94 local i = 1
95 for s in string.gfind(stack, "\n([^\n]*)") do
96 i = i + 1
97 if not string.find(s, file .. "%.lua:%d+:") then
98 error(message, i)
99 return
100 end
101 end
102 error(message, 2)
103 return
104 end
105 return condition
106 end
107  
108 local function argCheck(arg, num, kind, kind2, kind3, kind4)
109 if tostring(type(arg)) ~= kind then
110 if kind2 then
111 if tostring(type(arg)) ~= kind2 then
112 if kind3 then
113 if tostring(type(arg)) ~= kind3 then
114 if kind4 then
115 if tostring(type(arg)) ~= kind4 then
116 local _,_,func = string.find(debugstack(), "\n.-`(.-)'\n")
117 assert(false, format("Bad argument #%d to `%s' (%s, %s, %s, or %s expected, got %s)", num, func, kind, kind2, kind3, kind4, type(arg)))
118 end
119 else
120 local _,_,func = string.find(debugstack(), "\n.-`(.-)'\n")
121 assert(false, format("Bad argument #%d to `%s' (%s, %s, or %s expected, got %s)", num, func, kind, kind2, kind3, type(arg)))
122 end
123 end
124 else
125 local _,_,func = string.find(debugstack(), "\n.-`(.-)'\n")
126 assert(false, format("Bad argument #%d to `%s' (%s or %s expected, got %s)", num, func, kind, kind2, type(arg)))
127 end
128 end
129 else
130 local _,_,func = string.find(debugstack(), "\n.-`(.-)'\n")
131 assert(false, format("Bad argument #%d to `%s' (%s expected, got %s)", num, func, kind, type(arg)))
132 end
133 end
134 end
135  
136 local lib = {}
137  
138 local COPPER_ABBR = strlower(strsub(COPPER, 1, 1))
139 local SILVER_ABBR = strlower(strsub(SILVER, 1, 1))
140 local GOLD_ABBR = strlower(strsub(GOLD, 1, 1))
141  
142 local COLOR_WHITE = "ffffff"
143 local COLOR_GREEN = "00ff00"
144 local COLOR_RED = "ff0000"
145 local COLOR_COPPER = "eda55f"
146 local COLOR_SILVER = "c7c7cf"
147 local COLOR_GOLD = "ffd700"
148  
149 local inf = 1/0
150  
151 function lib:FormatMoneyExtended(value, colorize, textColor)
152 argCheck(value, 2, "number")
153 local gold = value / 10000
154 local silver = abs(mod(value / 100, 100))
155 local copper = abs(mod(value, 100))
156  
157 local color = COLOR_WHITE
158 if textColor then
159 if value > 0 then
160 color = COLOR_GREEN
161 elseif value < 0 then
162 color = COLOR_RED
163 end
164 end
165 if colorize then
166 if value == inf or value == -inf then
167 return format("|cff%s%s|r", color, value)
168 elseif value ~= value then
169 return format("|cff%s0|r|cff%s %s|r", COLOR_WHITE, COLOR_COPPER, COPPER)
170 elseif value >= 10000 or value <= -10000 then
171 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)
172 elseif value >= 100 or value <= -100 then
173 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)
174 else
175 return format("|cff%s%d|r|cff%s %s|r", color, copper, COLOR_COPPER, COPPER)
176 end
177 else
178 if value == inf or value == -inf then
179 return format("%s", value)
180 elseif value ~= value then
181 return format("0 %s", COPPER)
182 elseif value >= 10000 or value <= -10000 then
183 return format("%d %s %d %s %d %s", gold, GOLD, silver, SILVER, copper, COPPER)
184 elseif value >= 100 or value <= -100 then
185 return format("%d %s %d %s", silver, SILVER, copper, COPPER)
186 else
187 return format("%d %s", copper, COPPER)
188 end
189 end
190 end
191  
192 function lib:FormatMoneyFull(value, colorize, textColor)
193 argCheck(value, 2, "number")
194 local gold = value / 10000
195 local silver = abs(mod(value / 100, 100))
196 local copper = abs(mod(value, 100))
197  
198 local color = COLOR_WHITE
199 if textColor then
200 if value > 0 then
201 color = COLOR_GREEN
202 elseif value < 0 then
203 color = COLOR_RED
204 end
205 end
206 if colorize then
207 if value == inf or value == -inf then
208 return format("|cff%s%s|r", color, value)
209 elseif value ~= value then
210 return format("|cff%s0|r|cff%s%s|r", COLOR_WHITE, COLOR_COPPER, COPPER_ABBR)
211 elseif value >= 10000 or value <= -10000 then
212 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)
213 elseif value >= 100 or value <= -100 then
214 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)
215 else
216 return format("|cff%s%d|r|cff%s%s|r", color, copper, COLOR_COPPER, COPPER_ABBR)
217 end
218 else
219 if value == inf or value == -inf then
220 return format("%s", value)
221 elseif value ~= value then
222 return format("0%s", COPPER_ABBR)
223 elseif value >= 10000 or value <= -10000 then
224 return format("%d%s %d%s %d%s", gold, GOLD_ABBR, silver, SILVER_ABBR, copper, COPPER_ABBR)
225 elseif value >= 100 or value <= -100 then
226 return format("%d%s %d%s", silver, SILVER_ABBR, copper, COPPER_ABBR)
227 else
228 return format("%d%s", copper, COPPER_ABBR)
229 end
230 end
231 end
232  
233 function lib:FormatMoneyShort(copper, colorize, textColor)
234 argCheck(copper, 2, "number")
235 local color = COLOR_WHITE
236 if textColor then
237 if copper > 0 then
238 color = COLOR_GREEN
239 elseif copper < 0 then
240 color = COLOR_RED
241 end
242 end
243 if colorize then
244 if value == inf or value == -inf then
245 return format("|cff%s%s|r", color, value)
246 elseif value ~= value then
247 return format("|cff%s0|r|cff%s%s|r", COLOR_WHITE, COLOR_COPPER, COPPER_ABBR)
248 elseif copper >= 10000 or copper <= -10000 then
249 return format("|cff%s%.1f|r|cff%s%s|r", color, copper / 10000, COLOR_GOLD, GOLD_ABBR)
250 elseif copper >= 100 or copper <= -100 then
251 return format("|cff%s%.1f|r|cff%s%s|r", color, copper / 100, COLOR_SILVER, SILVER_ABBR)
252 else
253 return format("|cff%s%d|r|cff%s%s|r", color, copper, COLOR_COPPER, COPPER_ABBR)
254 end
255 else
256 if value == inf or value == -inf then
257 return format("%s", value)
258 elseif value ~= value then
259 return format("0%s", COPPER_ABBR)
260 elseif copper >= 10000 or copper <= -10000 then
261 return format("%.1f%s", copper / 10000, GOLD_ABBR)
262 elseif copper >= 100 or copper <= -100 then
263 return format("%.1f%s", copper / 100, SILVER_ABBR)
264 else
265 return format("%.0f%s", copper, COPPER_ABBR)
266 end
267 end
268 end
269  
270 function lib:FormatMoneyCondensed(value, colorize, textColor)
271 argCheck(value, 2, "number")
272 local negl = value < 0 and "(-" or ""
273 local negr = value < 0 and ")" or ""
274 if value < 0 then
275 if colorize and textColor then
276 negl = "|cffff0000-(|r"
277 negr = "|cffff0000)|r"
278 else
279 negl = "-("
280 negr = ")"
281 end
282 else
283 negl = ""
284 negr = ""
285 end
286 local gold = floor(math.abs(value) / 10000)
287 local silver = mod(floor(math.abs(value) / 100), 100)
288 local copper = mod(floor(math.abs(value)), 100)
289 if colorize then
290 if value == inf or value == -inf then
291 return format("%s|cff%s%s|r%s", negl, COLOR_COPPER, math.abs(value), negr)
292 elseif value ~= value then
293 return format("|cff%s0|r", COLOR_COPPER)
294 elseif gold ~= 0 then
295 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)
296 elseif silver ~= 0 then
297 return format("%s|cff%s%d|r.|cff%s%02d|r%s", negl, COLOR_SILVER, silver, COLOR_COPPER, copper, negr)
298 else
299 return format("%s|cff%s%d|r%s", negl, COLOR_COPPER, copper, negr)
300 end
301 else
302 if value == inf or value == -inf then
303 return tostring(value)
304 elseif value ~= value then
305 return "0"
306 elseif gold ~= 0 then
307 return format("%s%d.%02d.%02d%s", negl, gold, silver, copper, negr)
308 elseif silver ~= 0 then
309 return format("%s%d.%02d%s", negl, silver, copper, negr)
310 else
311 return format("%s%d%s", negl, copper, negr)
312 end
313 end
314 end
315  
316 local t
317 function lib:FormatDurationExtended(duration, colorize, hideSeconds)
318 argCheck(duration, 2, "number")
319 local negative = ""
320 if duration ~= duration then
321 duration = 0
322 end
323 if duration < 0 then
324 negative = "-"
325 duration = -duration
326 end
327 local days = floor(duration / 86400)
328 local hours = mod(floor(duration / 3600), 24)
329 local mins = mod(floor(duration / 60), 60)
330 local secs = mod(floor(duration), 60)
331 if not t then
332 t = {}
333 else
334 for k in pairs(t) do
335 t[k] = nil
336 end
337 table.setn(t, 0)
338 end
339 if not colorize then
340 if duration == nil or duration > 86400*365 then
341 return "Undetermined"
342 end
343 if days > 1 then
344 table.insert(t, format("%d %s", days, DAYS_ABBR_P1))
345 elseif days == 1 then
346 table.insert(t, format("%d %s", days, DAYS_ABBR))
347 end
348 if hours > 1 then
349 table.insert(t, format("%d %s", hours, HOURS_ABBR_P1))
350 elseif hours == 1 then
351 table.insert(t, format("%d %s", hours, HOURS_ABBR))
352 end
353 if mins > 1 then
354 table.insert(t, format("%d %s", mins, MINUTES_ABBR_P1))
355 elseif mins == 1 then
356 table.insert(t, format("%d %s", mins, MINUTES_ABBR))
357 end
358 if not hideSeconds then
359 if secs > 1 then
360 table.insert(t, format("%d %s", secs, SECONDS_ABBR_P1))
361 elseif secs == 1 then
362 table.insert(t, format("%d %s", secs, SECONDS_ABBR))
363 end
364 end
365 if table.getn(t) == 0 then
366 if not hideSeconds then
367 return "0 " .. SECONDS_ABBR_P1
368 else
369 return "0 " .. MINUTES_ABBR_P1
370 end
371 else
372 return negative .. table.concat(t, " ")
373 end
374 else
375 if duration == nil or duration > 86400*365 then
376 return "|cffffffffUndetermined|r"
377 end
378 if days > 1 then
379 table.insert(t, format("|cffffffff%d|r %s", days, DAYS_ABBR_P1))
380 elseif days == 1 then
381 table.insert(t, format("|cffffffff%d|r %s", days, DAYS_ABBR))
382 end
383 if hours > 1 then
384 table.insert(t, format("|cffffffff%d|r %s", hours, HOURS_ABBR_P1))
385 elseif hours == 1 then
386 table.insert(t, format("|cffffffff%d|r %s", hours, HOURS_ABBR))
387 end
388 if mins > 1 then
389 table.insert(t, format("|cffffffff%d|r %s", mins, MINUTES_ABBR_P1))
390 elseif mins == 1 then
391 table.insert(t, format("|cffffffff%d|r %s", mins, MINUTES_ABBR))
392 end
393 if not hideSeconds then
394 if secs > 1 then
395 table.insert(t, format("|cffffffff%d|r %s", secs, SECONDS_ABBR_P1))
396 elseif secs == 1 then
397 table.insert(t, format("|cffffffff%d|r %s", secs, SECONDS_ABBR))
398 end
399 end
400 if table.getn(t) == 0 then
401 if not hideSeconds then
402 return "|cffffffff0|r " .. SECONDS_ABBR_P1
403 else
404 return "|cffffffff0|r " .. MINUTES_ABBR_P1
405 end
406 elseif negative == "-" then
407 return "|cffffffff-|r" .. table.concat(t, " ")
408 else
409 return table.concat(t, " ")
410 end
411 end
412 end
413  
414 local DAY_ONELETTER_ABBR = string.gsub(DAY_ONELETTER_ABBR, "%s*%%d%s*", "")
415 local HOUR_ONELETTER_ABBR = string.gsub(HOUR_ONELETTER_ABBR, "%s*%%d%s*", "")
416 local MINUTE_ONELETTER_ABBR = string.gsub(MINUTE_ONELETTER_ABBR, "%s*%%d%s*", "")
417 local SECOND_ONELETTER_ABBR = string.gsub(SECOND_ONELETTER_ABBR, "%s*%%d%s*", "")
418  
419 function lib:FormatDurationFull(duration, colorize, hideSeconds)
420 argCheck(duration, 2, "number")
421 local negative = ""
422 if duration ~= duration then
423 duration = 0
424 end
425 if duration < 0 then
426 negative = "-"
427 duration = -duration
428 end
429 if not colorize then
430 if not hideSeconds then
431 if duration == nil or duration > 86400*365 then
432 return "Undetermined"
433 elseif duration >= 86400 then
434 return format("%s%d%s %02d%s %02d%s %02d%s", negative, duration/86400, DAY_ONELETTER_ABBR, mod(duration/3600, 24), HOUR_ONELETTER_ABBR, mod(duration/60, 60), MINUTE_ONELETTER_ABBR, mod(duration, 60), SECOND_ONELETTER_ABBR)
435 elseif duration >= 3600 then
436 return format("%s%d%s %02d%s %02d%s", negative, duration/3600, HOUR_ONELETTER_ABBR, mod(duration/60, 60), MINUTE_ONELETTER_ABBR, mod(duration, 60), SECOND_ONELETTER_ABBR)
437 elseif duration >= 120 then
438 return format("%s%d%s %02d%s", negative, duration/60, MINUTE_ONELETTER_ABBR, mod(duration, 60), SECOND_ONELETTER_ABBR)
439 else
440 return format("%s%d%s", negative, duration, SECOND_ONELETTER_ABBR)
441 end
442 else
443 if duration == nil or duration > 86400*365 then
444 return "Undetermined"
445 elseif duration >= 86400 then
446 return format("%s%d%s %02d%s %02d%s", negative, duration/86400, DAY_ONELETTER_ABBR, mod(duration/3600, 24), HOUR_ONELETTER_ABBR, mod(duration/60, 60), MINUTE_ONELETTER_ABBR)
447 elseif duration >= 3600 then
448 return format("%s%d%s %02d%s", negative, duration/3600, HOUR_ONELETTER_ABBR, mod(duration/60, 60), MINUTE_ONELETTER_ABBR)
449 else
450 return format("%s%d%s", negative, duration/60, MINUTE_ONELETTER_ABBR)
451 end
452 end
453 else
454 if not hideSeconds then
455 if duration == nil or duration > 86400*365 then
456 return "|cffffffffUndetermined|r"
457 elseif duration >= 86400 then
458 return format("|cffffffff%s%d|r%s |cffffffff%02d|r%s |cffffffff%02d|r%s |cffffffff%02d|r%s", negative, duration/86400, DAY_ONELETTER_ABBR, mod(duration/3600, 24), HOUR_ONELETTER_ABBR, mod(duration/60, 60), MINUTE_ONELETTER_ABBR, mod(duration, 60), SECOND_ONELETTER_ABBR)
459 elseif duration >= 3600 then
460 return format("|cffffffff%s%d|r%s |cffffffff%02d|r%s |cffffffff%02d|r%s", negative, duration/3600, HOUR_ONELETTER_ABBR, mod(duration/60, 60), MINUTE_ONELETTER_ABBR, mod(duration, 60), SECOND_ONELETTER_ABBR)
461 elseif duration >= 120 then
462 return format("|cffffffff%s%d|r%s |cffffffff%02d|r%s", negative, duration/60, MINUTE_ONELETTER_ABBR, mod(duration, 60), SECOND_ONELETTER_ABBR)
463 else
464 return format("|cffffffff%s%d|r%s", negative, duration, SECOND_ONELETTER_ABBR)
465 end
466 else
467 if duration == nil or duration > 86400*365 then
468 return "|cffffffffUndetermined|r"
469 elseif duration >= 86400 then
470 return format("|cffffffff%s%d|r%s |cffffffff%02d|r%s |cffffffff%02d|r%s", negative, duration/86400, DAY_ONELETTER_ABBR, mod(duration/3600, 24), HOUR_ONELETTER_ABBR, mod(duration/60, 60), MINUTE_ONELETTER_ABBR)
471 elseif duration >= 3600 then
472 return format("|cffffffff%s%d|r%s |cffffffff%02d|r%s", negative, duration/3600, HOUR_ONELETTER_ABBR, mod(duration/60, 60), MINUTE_ONELETTER_ABBR)
473 else
474 return format("|cffffffff%s%d|r%s", negative, duration/60, MINUTE_ONELETTER_ABBR)
475 end
476 end
477 end
478 end
479  
480 function lib:FormatDurationShort(duration, colorize, hideSeconds)
481 argCheck(duration, 2, "number")
482 local negative = ""
483 if duration ~= duration then
484 duration = 0
485 end
486 if duration < 0 then
487 negative = "-"
488 duration = -duration
489 end
490 if not colorize then
491 if duration == nil or duration >= 86400*365 then
492 return "***"
493 elseif duration >= 172800 then
494 return format("%s%.1f %s", negative, duration/86400, DAYS_ABBR_P1)
495 elseif duration >= 7200 then
496 return format("%s%.1f %s", negative, duration/3600, HOURS_ABBR_P1)
497 elseif duration >= 120 or not hideSeconds then
498 return format("%s%.1f %s", negative, duration/60, MINUTES_ABBR_P1)
499 else
500 return format("%s%.0f %s", negative, duration, SECONDS_ABBR_P1)
501 end
502 else
503 if duration == nil or duration >= 86400*365 then
504 return "|cffffffff***|r"
505 elseif duration >= 172800 then
506 return format("|cffffffff%s%.1f|r %s", negative, duration/86400, DAYS_ABBR_P1)
507 elseif duration >= 7200 then
508 return format("|cffffffff%s%.1f|r %s", negative, duration/3600, HOURS_ABBR_P1)
509 elseif duration >= 120 or not hideSeconds then
510 return format("|cffffffff%s%.1f|r %s", negative, duration/60, MINUTES_ABBR_P1)
511 else
512 return format("|cffffffff%s%.0f|r %s", negative, duration, SECONDS_ABBR_P1)
513 end
514 end
515 end
516  
517 function lib:FormatDurationCondensed(duration, colorize, hideSeconds)
518 argCheck(duration, 2, "number")
519 local negative = ""
520 if duration ~= duration then
521 duration = 0
522 end
523 if duration < 0 then
524 negative = "-"
525 duration = -duration
526 end
527 if not colorize then
528 if hideSeconds then
529 if duration == nil or duration >= 86400*365 then
530 return format("%s**%s **:**", negative, DAY_ONELETTER_ABBR)
531 elseif duration >= 86400 then
532 return format("%s%d%s %d:%02d", negative, duration/86400, DAY_ONELETTER_ABBR, mod(duration/3600, 24), mod(duration/60, 60))
533 else
534 return format("%s%d:%02d", negative, duration/3600, mod(duration/60, 60))
535 end
536 else
537 if duration == nil or duration >= 86400*365 then
538 return negative .. "**:**:**:**"
539 elseif duration >= 86400 then
540 return format("%s%d%s %d:%02d:%02d", negative, duration/86400, DAY_ONELETTER_ABBR, mod(duration/3600, 24), mod(duration/60, 60), mod(duration, 60))
541 elseif duration >= 3600 then
542 return format("%s%d:%02d:%02d", negative, duration/3600, mod(duration/60, 60), mod(duration, 60))
543 else
544 return format("%s%d:%02d", negative, duration/60, mod(duration, 60))
545 end
546 end
547 else
548 if hideSeconds then
549 if duration == nil or duration >= 86400*365 then
550 return format("|cffffffff%s**|r%s |cffffffff**|r:|cffffffff**|r", negative, DAY_ONELETTER_ABBR)
551 elseif duration >= 86400 then
552 return format("|cffffffff%s%d|r%s |cffffffff%d|r:|cffffffff%02d|r", negative, duration/86400, DAY_ONELETTER_ABBR, mod(duration/3600, 24), mod(duration/60, 60))
553 else
554 return format("|cffffffff%s%d|r:|cffffffff%02d|r", negative, duration/3600, mod(duration/60, 60))
555 end
556 else
557 if duration == nil or duration >= 86400*365 then
558 return format("|cffffffff%s**|r%s |cffffffff**|r:|cffffffff**|r:|cffffffff**|r", negative, DAY_ONELETTER_ABBR)
559 elseif duration >= 86400 then
560 return format("|cffffffff%s%d|r%s |cffffffff%d|r:|cffffffff%02d|r:|cffffffff%02d|r", negative, duration/86400, DAY_ONELETTER_ABBR, mod(duration/3600, 24), mod(duration/60, 60), mod(duration, 60))
561 elseif duration >= 3600 then
562 return format("|cffffffff%s%d|r:|cffffffff%02d|r:|cffffffff%02d|r", negative, duration/3600, mod(duration/60, 60), mod(duration, 60))
563 else
564 return format("|cffffffff%s%d|r:|cffffffff%02d|r", negative, duration/60, mod(duration, 60))
565 end
566 end
567 end
568 end
569  
570 function lib:GetLibraryVersion()
571 return MAJOR_VERSION, MINOR_VERSION
572 end
573  
574 function lib:LibActivate(stub, oldLib, oldList)
575 end
576  
577 function lib:LibDeactivate(stub)
578 end
579  
580 AbacusLib:Register(lib)
581 lib = nil