port all time formats from retail

i may restruct this in future, or even make a lib, because i dont like to have custom locales mixed in here
This commit is contained in:
NoM0Re
2025-02-09 20:46:36 +01:00
parent 1ed8242c53
commit 75eb0fd437
14 changed files with 842 additions and 13 deletions
+27
View File
@@ -2365,3 +2365,30 @@ L["Shadow"] = "Schatten"
L["Subtlety"] = "Täuschung"
L["Survival"] = "Überleben"
L["Unholy"] = "Unheilig"
L["SHORTDATE_EU"] = "%1$d.%2$d.%3$02d"
L["D_SECONDS"] = "%d |4Sekunde:Sekunden;"
L["SECONDS_ABBR"] = "%d |4Sek.:Sek.;"
L["SECOND_ONELETTER_ABBR"] = "%d s"
L["D_MINUTES"] = "%d |4Minute:Minuten;"
L["MINUTES_ABBR"] = "%d |4Min.:Min.;"
L["MINUTE_ONELETTER_ABBR"] = "%d m"
L["D_HOURS"] = "%d |4Stunde:Stunden;"
L["HOURS_ABBR"] = "%d |4Std.:Std.;"
L["HOUR_ONELETTER_ABBR"] = "%d h"
L["D_DAYS"] = "%d |4Tag:Tage;"
L["DAYS_ABBR"] = "%d |4Tag:Tage;"
L["DAY_ONELETTER_ABBR"] = "%d d"
L["LESS_THAN_OPERAND"] = "< %s"
L["TIME_UNIT_DELIMITER"] = " "
L["HOURS_MINUTES_SECONDS"] = "%.2d:%.2d:%.2d"
L["MINUTES_SECONDS"] = "%.2d:%.2d"
L["SHORTDATE"] = "%1$02d.%2$02d.%3$02d"
L["SHORTDATENOYEAR"] = "%1$02d.%2$d."
L["SHORTDATENOYEAR_EU"] = "%1$d.%2$d."
L["DECIMAL_SEPERATOR"] = ","
L["SECOND_NUMBER_CAP"] = " M"
L["FIRST_NUMBER_CAP"] = " K"
L["FIRST_NUMBER_CAP_NO_SPACE"] = "K"
L["FOURTH_NUMBER_CAP_NO_SPACE"] = " Bio."
L["SECOND_NUMBER_CAP_NO_SPACE"] = " Mio."
L["THIRD_NUMBER_CAP_NO_SPACE"] = " Mrd."
+27
View File
@@ -1546,6 +1546,33 @@ L["Shadow"] = "Shadow"
L["Subtlety"] = "Subtlety"
L["Survival"] = "Survival"
L["Unholy"] = "Unholy"
L["SHORTDATE_EU"] = "%1$d/%2$d/%3$02d"
L["D_SECONDS"] = "%d |4Second:Seconds;"
L["SECONDS_ABBR"] = "%d |4Sec:Sec;"
L["SECOND_ONELETTER_ABBR"] = "%d s"
L["D_MINUTES"] = "%d |4Minute:Minutes;"
L["MINUTES_ABBR"] = "%d |4Min:Min;"
L["MINUTE_ONELETTER_ABBR"] = "%d m"
L["D_HOURS"] = "%d |4Hour:Hours;"
L["HOURS_ABBR"] = "%d |4Hr:Hr;"
L["HOUR_ONELETTER_ABBR"] = "%d h"
L["D_DAYS"] = "%d |4Day:Days;"
L["DAYS_ABBR"] = "%d |4Day:Days;"
L["DAY_ONELETTER_ABBR"] = "%d d"
L["LESS_THAN_OPERAND"] = "< %s"
L["TIME_UNIT_DELIMITER"] = " "
L["HOURS_MINUTES_SECONDS"] = "%.2d:%.2d:%.2d"
L["MINUTES_SECONDS"] = "%.2d:%.2d"
L["SHORTDATE"] = "%2$d/%1$02d/%3$02d"
L["SHORTDATENOYEAR"] = "%2$d/%1$02d"
L["SHORTDATENOYEAR_EU"] = "%1$d/%2$d"
L["DECIMAL_SEPERATOR"] = "."
L["SECOND_NUMBER_CAP"] = " M"
L["FIRST_NUMBER_CAP"] = " K"
L["FIRST_NUMBER_CAP_NO_SPACE"] = "K"
L["FOURTH_NUMBER_CAP_NO_SPACE"] = "T"
L["SECOND_NUMBER_CAP_NO_SPACE"] = "M"
L["THIRD_NUMBER_CAP_NO_SPACE"] = "B"
-- Make missing translations available
setmetatable(WeakAuras.L, {__index = function(self, key)
+27
View File
@@ -1484,3 +1484,30 @@ L["Shadow"] = "Sombras"
L["Subtlety"] = "Sutileza"
L["Survival"] = "Supervivencia"
L["Unholy"] = "Profano"
L["SHORTDATE_EU"] = "%1$d/%2$d/%3$02d"
L["D_SECONDS"] = "%d |4segundo:segundos;"
L["SECONDS_ABBR"] = "%d |4s:s;"
L["SECOND_ONELETTER_ABBR"] = "%d s"
L["D_MINUTES"] = "%d |4minuto:minutos;"
L["MINUTES_ABBR"] = "%d |4min:min;"
L["MINUTE_ONELETTER_ABBR"] = "%d m"
L["D_HOURS"] = "%d |4hora:horas;"
L["HOURS_ABBR"] = "%d |4h:h;"
L["HOUR_ONELETTER_ABBR"] = "%d h"
L["D_DAYS"] = "%d |4día:días;"
L["DAYS_ABBR"] = "%d |4día:días;"
L["DAY_ONELETTER_ABBR"] = "%d d"
L["LESS_THAN_OPERAND"] = "< %s"
L["TIME_UNIT_DELIMITER"] = " "
L["HOURS_MINUTES_SECONDS"] = "%.2d:%.2d:%.2d"
L["MINUTES_SECONDS"] = "%.2d:%.2d"
L["SHORTDATE"] = "%1$02d/%2$02d/%3$02d"
L["SHORTDATENOYEAR"] = "%1$02d/%2$d"
L["SHORTDATENOYEAR_EU"] = "%1$d/%2$d"
L["DECIMAL_SEPERATOR"] = "."
L["SECOND_NUMBER_CAP"] = "mill."
L["FIRST_NUMBER_CAP"] = "mil"
L["FIRST_NUMBER_CAP_NO_SPACE"] = "mil"
L["FOURTH_NUMBER_CAP_NO_SPACE"] = "T"
L["SECOND_NUMBER_CAP_NO_SPACE"] = "mill."
L["THIRD_NUMBER_CAP_NO_SPACE"] = "MM"
+27
View File
@@ -1485,3 +1485,30 @@ L["Shadow"] = "Sombra"
L["Subtlety"] = "Sutileza"
L["Survival"] = "Supervivencia"
L["Unholy"] = "Profano"
L["SHORTDATE_EU"] = "%1$d/%2$d/%3$02d"
L["D_SECONDS"] = "%d |4segundo:segundos;"
L["SECONDS_ABBR"] = "%d |4s:s;"
L["SECOND_ONELETTER_ABBR"] = "%d s"
L["D_MINUTES"] = "%d |4minuto:minutos;"
L["MINUTES_ABBR"] = "%d |4min:min;"
L["MINUTE_ONELETTER_ABBR"] = "%d m"
L["D_HOURS"] = "%d |4Hora:Horas;"
L["HOURS_ABBR"] = "%d |4h:h;"
L["HOUR_ONELETTER_ABBR"] = "%d h"
L["D_DAYS"] = "%d |4Día:Días;"
L["DAYS_ABBR"] = "%d |4Día:Días;"
L["DAY_ONELETTER_ABBR"] = "%d d"
L["LESS_THAN_OPERAND"] = "< %s"
L["TIME_UNIT_DELIMITER"] = " "
L["HOURS_MINUTES_SECONDS"] = "%.2d:%.2d:%.2d"
L["MINUTES_SECONDS"] = "%.2d:%.2d"
L["SHORTDATE"] = "%1$02d/%2$02d/%3$02d"
L["SHORTDATENOYEAR"] = "%1$02d/%2$d"
L["SHORTDATENOYEAR_EU"] = "%1$d/%2$d"
L["DECIMAL_SEPERATOR"] = "."
L["SECOND_NUMBER_CAP"] = "mill."
L["FIRST_NUMBER_CAP"] = "mil"
L["FIRST_NUMBER_CAP_NO_SPACE"] = "mil"
L["FOURTH_NUMBER_CAP_NO_SPACE"] = "T"
L["SECOND_NUMBER_CAP_NO_SPACE"] = "mill."
L["THIRD_NUMBER_CAP_NO_SPACE"] = "B"
+27
View File
@@ -2155,3 +2155,30 @@ L["Shadow"] = "Ombre"
L["Subtlety"] = "Finesse"
L["Survival"] = "Survie"
L["Unholy"] = "Impie"
L["SHORTDATE_EU"] = "%1$d/%2$d/%3$02d"
L["D_SECONDS"] = "%d |4seconde:secondes;"
L["SECONDS_ABBR"] = "%d s"
L["SECOND_ONELETTER_ABBR"] = "%d s"
L["D_MINUTES"] = "%d |4minute:minutes;"
L["MINUTES_ABBR"] = "%d |4min:min;"
L["MINUTE_ONELETTER_ABBR"] = "%d m"
L["D_HOURS"] = "%d |4heure:heures;"
L["HOURS_ABBR"] = "%d |4h:h;"
L["HOUR_ONELETTER_ABBR"] = "%d h"
L["D_DAYS"] = "%d |4jour:jours;"
L["DAYS_ABBR"] = "%d |4jour:jours;"
L["DAY_ONELETTER_ABBR"] = "%d j"
L["LESS_THAN_OPERAND"] = "< %s"
L["TIME_UNIT_DELIMITER"] = " "
L["HOURS_MINUTES_SECONDS"] = "%.2d:%.2d:%.2d"
L["MINUTES_SECONDS"] = "%.2d:%.2d"
L["SHORTDATE"] = "%1$02d/%2$d/%3$02d"
L["SHORTDATENOYEAR"] = "%1$d/%2$02d"
L["SHORTDATENOYEAR_EU"] = "%1$d/%2$d"
L["DECIMAL_SEPERATOR"] = ","
L["SECOND_NUMBER_CAP"] = " m"
L["FIRST_NUMBER_CAP"] = " k"
L["FIRST_NUMBER_CAP_NO_SPACE"] = " k"
L["FOURTH_NUMBER_CAP_NO_SPACE"] = " T"
L["SECOND_NUMBER_CAP_NO_SPACE"] = " M"
L["THIRD_NUMBER_CAP_NO_SPACE"] = " G"
+27
View File
@@ -2664,3 +2664,30 @@ L["Shadow"] = "Shadow"
L["Subtlety"] = "Subtlety"
L["Survival"] = "Survival"
L["Unholy"] = "Unholy"
L["SHORTDATE_EU"] = "%1$02d/%2$02d/%3$02d"
L["D_SECONDS"] = "%d s"
L["SECONDS_ABBR"] = "%d s"
L["SECOND_ONELETTER_ABBR"] = "%d s"
L["D_MINUTES"] = "%d |4minuto:minuti;"
L["MINUTES_ABBR"] = "%d |4min:min;"
L["MINUTE_ONELETTER_ABBR"] = "%d m"
L["D_HOURS"] = "%d |4ora:ore;"
L["HOURS_ABBR"] = "%d |4ora:ore;"
L["HOUR_ONELETTER_ABBR"] = "%d o"
L["D_DAYS"] = "%d |4giorno:giorni;"
L["DAYS_ABBR"] = "%d |4giorno:giorni;"
L["DAY_ONELETTER_ABBR"] = "%d g"
L["LESS_THAN_OPERAND"] = "< %s"
L["TIME_UNIT_DELIMITER"] = " "
L["HOURS_MINUTES_SECONDS"] = "%.2d:%.2d:%.2d"
L["MINUTES_SECONDS"] = "%.2d:%.2d"
L["SHORTDATE"] = "%1$02d/%2$02d/%3$02d"
L["SHORTDATENOYEAR"] = "%1$d/%2$02d"
L["SHORTDATENOYEAR_EU"] = "%1$d/%2$d"
L["DECIMAL_SEPERATOR"] = ","
L["SECOND_NUMBER_CAP"] = " M"
L["FIRST_NUMBER_CAP"] = " K"
L["FIRST_NUMBER_CAP_NO_SPACE"] = "K"
L["FOURTH_NUMBER_CAP_NO_SPACE"] = "Bld"
L["SECOND_NUMBER_CAP_NO_SPACE"] = "M"
L["THIRD_NUMBER_CAP_NO_SPACE"] = "Mld"
+27
View File
@@ -1541,3 +1541,30 @@ L["Shadow"] = "암흑"
L["Subtlety"] = "잠행"
L["Survival"] = "생존"
L["Unholy"] = "부정"
L["SHORTDATE_EU"] = "%1$d/%2$d/%3$02d"
L["D_SECONDS"] = "%d초"
L["SECONDS_ABBR"] = "%d초"
L["SECOND_ONELETTER_ABBR"] = "%d초"
L["D_MINUTES"] = "%d분"
L["MINUTES_ABBR"] = "%d분"
L["MINUTE_ONELETTER_ABBR"] = "%d분"
L["D_HOURS"] = "%d시간"
L["HOURS_ABBR"] = "%d시간"
L["HOUR_ONELETTER_ABBR"] = "%d시간"
L["D_DAYS"] = "%d일"
L["DAYS_ABBR"] = "%d일"
L["DAY_ONELETTER_ABBR"] = "%d일"
L["LESS_THAN_OPERAND"] = "< %s"
L["TIME_UNIT_DELIMITER"] = " "
L["HOURS_MINUTES_SECONDS"] = "%.2d:%.2d:%.2d"
L["MINUTES_SECONDS"] = "%.2d:%.2d"
L["SHORTDATE"] = "%3$02d/%2$d/%1$02d"
L["SHORTDATENOYEAR"] = "%2$d/%1$02d"
L["SHORTDATENOYEAR_EU"] = "%1$d/%2$d"
L["DECIMAL_SEPERATOR"] = "."
L["SECOND_NUMBER_CAP"] = ""
L["FIRST_NUMBER_CAP"] = ""
L["FIRST_NUMBER_CAP_NO_SPACE"] = ""
L["FOURTH_NUMBER_CAP_NO_SPACE"] = ""
L["SECOND_NUMBER_CAP_NO_SPACE"] = ""
L["THIRD_NUMBER_CAP_NO_SPACE"] = ""
+27
View File
@@ -2589,3 +2589,30 @@ L["Shadow"] = "Shadow"
L["Subtlety"] = "Subtlety"
L["Survival"] = "Survival"
L["Unholy"] = "Unholy"
L["SHORTDATE_EU"] = "%1$d/%2$d/%3$02d"
L["D_SECONDS"] = "%d |4segundo:segundos;"
L["SECONDS_ABBR"] = "%d |4s:s;"
L["SECOND_ONELETTER_ABBR"] = "%d s"
L["D_MINUTES"] = "%d |4minuto:minutos;"
L["MINUTES_ABBR"] = "%d |4min:min;"
L["MINUTE_ONELETTER_ABBR"] = "%d min"
L["D_HOURS"] = "%d |4hora:horas;"
L["HOURS_ABBR"] = "%d |4H:H;"
L["HOUR_ONELETTER_ABBR"] = "%d h"
L["D_DAYS"] = "%d |4dia:dias;"
L["DAYS_ABBR"] = "%d |4dia:dias;"
L["DAY_ONELETTER_ABBR"] = "%d d"
L["LESS_THAN_OPERAND"] = "< %s"
L["TIME_UNIT_DELIMITER"] = " "
L["HOURS_MINUTES_SECONDS"] = "%.2d:%.2d:%.2d"
L["MINUTES_SECONDS"] = "%.2d:%.2d"
L["SHORTDATE"] = "%1$02d/%2$d/%3$02d"
L["SHORTDATENOYEAR"] = "%1$02d/%2$d"
L["SHORTDATENOYEAR_EU"] = "%1$d/%2$d"
L["DECIMAL_SEPERATOR"] = "."
L["SECOND_NUMBER_CAP"] = " M"
L["FIRST_NUMBER_CAP"] = " K"
L["FIRST_NUMBER_CAP_NO_SPACE"] = "K"
L["FOURTH_NUMBER_CAP_NO_SPACE"] = "T"
L["SECOND_NUMBER_CAP_NO_SPACE"] = "M"
L["THIRD_NUMBER_CAP_NO_SPACE"] = "B"
+27
View File
@@ -1530,3 +1530,30 @@ L["Shadow"] = "Темная магия"
L["Subtlety"] = "Скрытность"
L["Survival"] = "Выживание"
L["Unholy"] = "Нечестивость"
L["SHORTDATE_EU"] = "%1$d/%2$d/%3$02d"
L["D_SECONDS"] = "%d c"
L["SECONDS_ABBR"] = "%d с."
L["SECOND_ONELETTER_ABBR"] = "%d с."
L["D_MINUTES"] = "%d |4минута:минуты:минут;"
L["MINUTES_ABBR"] = "%d мин."
L["MINUTE_ONELETTER_ABBR"] = "%d м."
L["D_HOURS"] = "%d ч."
L["HOURS_ABBR"] = "%d ч."
L["HOUR_ONELETTER_ABBR"] = "%d ч."
L["D_DAYS"] = "%d д."
L["DAYS_ABBR"] = "%d д."
L["DAY_ONELETTER_ABBR"] = "%d д."
L["LESS_THAN_OPERAND"] = "< %s"
L["TIME_UNIT_DELIMITER"] = " "
L["HOURS_MINUTES_SECONDS"] = "%.2d:%.2d:%.2d"
L["MINUTES_SECONDS"] = "%.2d:%.2d"
L["SHORTDATE"] = "%1$d/%2$02d/%3$02d"
L["SHORTDATENOYEAR"] = "%1$02d/%2$d"
L["SHORTDATENOYEAR_EU"] = "%1$d/%2$d"
L["DECIMAL_SEPERATOR"] = ","
L["SECOND_NUMBER_CAP"] = "M"
L["FIRST_NUMBER_CAP"] = "T"
L["FIRST_NUMBER_CAP_NO_SPACE"] = "Т"
L["FOURTH_NUMBER_CAP_NO_SPACE"] = "T"
L["SECOND_NUMBER_CAP_NO_SPACE"] = "М"
L["THIRD_NUMBER_CAP_NO_SPACE"] = "МЛРД"
+27
View File
@@ -1550,3 +1550,30 @@ L["Shadow"] = "暗影魔法"
L["Subtlety"] = "敏锐"
L["Survival"] = "生存技能"
L["Unholy"] = "邪恶"
L["SHORTDATE_EU"] = "%1$d/%2$d/%3$02d"
L["D_SECONDS"] = "%d|4秒:秒;"
L["SECONDS_ABBR"] = "%d|4秒:秒;"
L["SECOND_ONELETTER_ABBR"] = "%d s"
L["D_MINUTES"] = "%d|4分钟:分钟;"
L["MINUTES_ABBR"] = "%d|4分钟:分钟;"
L["MINUTE_ONELETTER_ABBR"] = "%d m"
L["D_HOURS"] = "%d|4小时:小时;"
L["HOURS_ABBR"] = "%d|4小时:小时;"
L["HOUR_ONELETTER_ABBR"] = "%d h"
L["D_DAYS"] = "%d|4天:天;"
L["DAYS_ABBR"] = "%d|4天:天;"
L["DAY_ONELETTER_ABBR"] = "%d d"
L["LESS_THAN_OPERAND"] = "< %s"
L["TIME_UNIT_DELIMITER"] = " "
L["HOURS_MINUTES_SECONDS"] = "%.2d:%.2d:%.2d"
L["MINUTES_SECONDS"] = "%.2d%.2d"
L["SHORTDATE"] = "%2$d/%1$02d/%3$02d"
L["SHORTDATENOYEAR"] = "%2$d/%1$02d"
L["SHORTDATENOYEAR_EU"] = "%1$d/%2$d"
L["DECIMAL_SEPERATOR"] = "."
L["SECOND_NUMBER_CAP"] = "亿"
L["FIRST_NUMBER_CAP"] = ""
L["FIRST_NUMBER_CAP_NO_SPACE"] = ""
L["FOURTH_NUMBER_CAP_NO_SPACE"] = "T"
L["SECOND_NUMBER_CAP_NO_SPACE"] = "亿"
L["THIRD_NUMBER_CAP_NO_SPACE"] = "B"
+27
View File
@@ -1515,3 +1515,30 @@ L["Shadow"] = "暗影"
L["Subtlety"] = "敏銳"
L["Survival"] = "生存"
L["Unholy"] = "穢邪"
L["SHORTDATE_EU"] = "%1$d/%2$d/%3$02d"
L["D_SECONDS"] = "%d秒"
L["SECONDS_ABBR"] = "%d秒"
L["SECOND_ONELETTER_ABBR"] = "%d秒"
L["D_MINUTES"] = "%d分鐘"
L["MINUTES_ABBR"] = "%d分鐘"
L["MINUTE_ONELETTER_ABBR"] = "%d分"
L["D_HOURS"] = "%d小時"
L["HOURS_ABBR"] = "%d小時"
L["HOUR_ONELETTER_ABBR"] = "%d小時"
L["D_DAYS"] = "%d天"
L["DAYS_ABBR"] = "%d天"
L["DAY_ONELETTER_ABBR"] = "%d天"
L["LESS_THAN_OPERAND"] = "< %s"
L["TIME_UNIT_DELIMITER"] = " "
L["HOURS_MINUTES_SECONDS"] = "%.2d:%.2d:%.2d"
L["MINUTES_SECONDS"] = "%.2d:%.2d"
L["SHORTDATE"] = "%2$d-%1$02d-%3$02d"
L["SHORTDATENOYEAR"] = "%2$d/%1$02d"
L["SHORTDATENOYEAR_EU"] = "%1$d/%2$d"
L["DECIMAL_SEPERATOR"] = "."
L["SECOND_NUMBER_CAP"] = ""
L["FIRST_NUMBER_CAP"] = ""
L["FIRST_NUMBER_CAP_NO_SPACE"] = ""
L["FOURTH_NUMBER_CAP_NO_SPACE"] = "T"
L["SECOND_NUMBER_CAP_NO_SPACE"] = ""
L["THIRD_NUMBER_CAP_NO_SPACE"] = "B"
+466
View File
@@ -0,0 +1,466 @@
if not WeakAuras.IsLibsOK() then return end
local AddonName, Private = ...
local WeakAuras = WeakAuras
local L = WeakAuras.L
-- Lua APIs
local time, format, floor, ceil = time, format, floor, ceil
-- WoW APIs
local GetLocale = GetLocale
local TIME_UTIL_WHITE_SPACE_STRIPPABLE = true;
local SECONDS_PER_MIN = 60;
local SECONDS_PER_HOUR = 60 * SECONDS_PER_MIN;
local SECONDS_PER_DAY = 24 * SECONDS_PER_HOUR;
local SECONDS_PER_MONTH = 30 * SECONDS_PER_DAY;
local SECONDS_PER_YEAR = 12 * SECONDS_PER_MONTH;
function SecondsToMinutes(seconds)
return seconds / SECONDS_PER_MIN;
end
function MinutesToSeconds(minutes)
return minutes * SECONDS_PER_MIN;
end
function HasTimePassed(testTime, amountOfTime)
return ((time() - testTime) >= amountOfTime);
end
SecondsFormatter = {};
SecondsFormatterConstants =
{
ZeroApproximationThreshold = 0,
ConvertToLower = true,
DontConvertToLower = false,
RoundUpLastUnit = true,
DontRoundUpLastUnit = false,
}
SecondsFormatter.Abbreviation =
{
None = 1, -- seconds, minutes, hours...
Truncate = 2, -- sec, min, hr...
OneLetter = 3, -- s, m, h...
}
SecondsFormatter.Interval = {
Seconds = 1,
Minutes = 2,
Hours = 3,
Days = 4,
}
SecondsFormatter.IntervalDescription = {
[SecondsFormatter.Interval.Seconds] = {seconds = 1, formatString = { L["D_SECONDS"], L["SECONDS_ABBR"], L["SECOND_ONELETTER_ABBR"]}},
[SecondsFormatter.Interval.Minutes] = {seconds = SECONDS_PER_MIN, formatString = {L["D_MINUTES"], L["MINUTES_ABBR"], L["MINUTE_ONELETTER_ABBR"]}},
[SecondsFormatter.Interval.Hours] = {seconds = SECONDS_PER_HOUR, formatString = {L["D_HOURS"], L["HOURS_ABBR"], L["HOUR_ONELETTER_ABBR"]}},
[SecondsFormatter.Interval.Days] = {seconds = SECONDS_PER_DAY, formatString = {L["D_DAYS"], L["DAYS_ABBR"], L["DAY_ONELETTER_ABBR"]}},
}
--[[ Seconds formatter to standardize representations of seconds. When adding a new formatter
please consider if a prexisting formatter suits your needs, otherwise, before adding a new formatter,
consider adding it to a file appropriate to it's intended use. For example, "WorldQuestsSecondsFormatter"
could be added to QuestUtil.h so it's immediately apparent the scenarios the formatter is appropriate.]]
SecondsFormatterMixin = {}
-- defaultAbbreviation: the default abbreviation for the format. Can be overrridden in SecondsFormatterMixin:Format()
-- approximationSeconds: threshold for representing the seconds as an approximation (ex. "< 2 hours").
-- roundUpLastUnit: determines if the last unit in the output format string is ceiled (floored by default).
-- convertToLower: converts the format string to lowercase.
function SecondsFormatterMixin:Init(approximationSeconds, defaultAbbreviation, roundUpLastUnit, convertToLower)
self:SetApproximationSeconds(approximationSeconds or 0);
self:SetMinInterval(SecondsFormatter.Interval.Seconds);
self:SetDefaultAbbreviation(defaultAbbreviation or SecondsFormatter.Abbreviation.None);
self:SetCanRoundUpLastUnit(roundUpLastUnit or false);
self:SetDesiredUnitCount(2);
self:SetStripIntervalWhitespace(false);
self:SetConvertToLower(convertToLower or false);
end
function SecondsFormatterMixin:SetStripIntervalWhitespace(strip)
self.stripIntervalWhitespace = strip;
end
function SecondsFormatterMixin:GetStripIntervalWhitespace()
return self.stripIntervalWhitespace;
end
function SecondsFormatterMixin:SetConvertToLower(convertToLower)
self.convertToLower = convertToLower;
end
function SecondsFormatterMixin:GetMaxInterval()
return #SecondsFormatter.IntervalDescription;
end
function SecondsFormatterMixin:GetIntervalDescription(interval)
return SecondsFormatter.IntervalDescription[interval];
end
function SecondsFormatterMixin:GetIntervalSeconds(interval)
local intervalDescription = self:GetIntervalDescription(interval);
return intervalDescription and intervalDescription.seconds or nil;
end
function SecondsFormatterMixin:CanApproximate(seconds)
return (seconds > 0 and seconds < self:GetApproximationSeconds());
end
function SecondsFormatterMixin:SetDefaultAbbreviation(defaultAbbreviation)
self.defaultAbbreviation = defaultAbbreviation;
end
function SecondsFormatterMixin:GetDefaultAbbreviation()
return self.defaultAbbreviation;
end
function SecondsFormatterMixin:SetApproximationSeconds(approximationSeconds)
self.approximationSeconds = approximationSeconds;
end
function SecondsFormatterMixin:GetApproximationSeconds()
return self.approximationSeconds;
end
function SecondsFormatterMixin:SetCanRoundUpLastUnit(roundUpLastUnit)
self.roundUpLastUnit = roundUpLastUnit;
end
function SecondsFormatterMixin:CanRoundUpLastUnit()
return self.roundUpLastUnit;
end
function SecondsFormatterMixin:SetDesiredUnitCount(unitCount)
self.unitCount = unitCount;
end
function SecondsFormatterMixin:GetDesiredUnitCount(seconds)
-- seconds ignored in base implementation, but instances of this mixin can override this function
return self.unitCount;
end
function SecondsFormatterMixin:SetMinInterval(interval)
self.minInterval = interval;
end
function SecondsFormatterMixin:GetMinInterval(seconds)
-- seconds ignored in base implementation, but instances of this mixin can override this function
return self.minInterval;
end
function SecondsFormatterMixin:GetFormatString(interval, abbreviation, convertToLower)
local intervalDescription = self:GetIntervalDescription(interval);
local formatString = intervalDescription.formatString[abbreviation];
if convertToLower then
formatString = formatString:lower();
end
local strip = TIME_UTIL_WHITE_SPACE_STRIPPABLE and self:GetStripIntervalWhitespace();
return strip and formatString:gsub(" ", "") or formatString;
end
function SecondsFormatterMixin:FormatZero(abbreviation, toLower)
local minInterval = self:GetMinInterval(seconds);
local formatString = self:GetFormatString(minInterval, abbreviation);
return formatString:format(0);
end
function SecondsFormatterMixin:FormatMillseconds(millseconds, abbreviation)
return self:Format(millseconds/1000, abbreviation);
end
function SecondsFormatterMixin:Format(seconds, abbreviation)
if (seconds == nil) then
return "";
end
seconds = math.ceil(seconds);
abbreviation = abbreviation or self:GetDefaultAbbreviation();
if (seconds <= 0) then
return self:FormatZero(abbreviation);
end
local minInterval = self:GetMinInterval(seconds);
local maxInterval = self:GetMaxInterval();
if (self:CanApproximate(seconds)) then
local interval = math.max(minInterval, SecondsFormatter.Interval.Minutes);
while (interval < maxInterval) do
local nextInterval = interval + 1;
if (seconds > self:GetIntervalSeconds(nextInterval)) then
interval = nextInterval;
else
break;
end
end
local formatString = self:GetFormatString(interval, abbreviation, self.convertToLower);
local unit = formatString:format(math.ceil(seconds / self:GetIntervalSeconds(interval)));
return string.format(L["LESS_THAN_OPERAND"], unit);
end
local output = "";
local appendedCount = 0;
local desiredCount = self:GetDesiredUnitCount(seconds);
local convertToLower = self.convertToLower;
local currentInterval = maxInterval;
while ((appendedCount < desiredCount) and (currentInterval >= minInterval)) do
local intervalDescription = self:GetIntervalDescription(currentInterval);
local intervalSeconds = intervalDescription.seconds;
if (seconds >= intervalSeconds) then
appendedCount = appendedCount + 1;
if (output ~= "") then
output = output..L["TIME_UNIT_DELIMITER"];
end
local formatString = self:GetFormatString(currentInterval, abbreviation, convertToLower);
local quotient = seconds / intervalSeconds;
if (quotient > 0) then
if (self:CanRoundUpLastUnit() and ((minInterval == currentInterval) or (appendedCount == desiredCount))) then
output = output..formatString:format(math.ceil(quotient));
else
output = output..formatString:format(math.floor(quotient));
end
else
break;
end
seconds = math.fmod(seconds, intervalSeconds);
end
currentInterval = currentInterval - 1;
end
-- Return the zero format if an acceptable representation couldn't be formed.
if (output == "") then
return self:FormatZero(abbreviation);
end
return output;
end
function ConvertSecondsToUnits(timestamp)
timestamp = math.max(timestamp, 0);
local days = math.floor(timestamp / SECONDS_PER_DAY);
timestamp = timestamp - (days * SECONDS_PER_DAY);
local hours = math.floor(timestamp / SECONDS_PER_HOUR);
timestamp = timestamp - (hours * SECONDS_PER_HOUR);
local minutes = math.floor(timestamp / SECONDS_PER_MIN);
timestamp = timestamp - (minutes * SECONDS_PER_MIN);
local seconds = math.floor(timestamp);
local milliseconds = timestamp - seconds;
return {
days=days,
hours=hours,
minutes=minutes,
seconds=seconds,
milliseconds=milliseconds,
}
end
function SecondsToClock(seconds, displayZeroHours)
local units = ConvertSecondsToUnits(seconds);
if units.hours > 0 or displayZeroHours then
return format(L["HOURS_MINUTES_SECONDS"], units.hours, units.minutes, units.seconds);
else
return format(L["MINUTES_SECONDS"], units.minutes, units.seconds);
end
end
-- Deprecated. See SecondsFormatter for intended replacement
function SecondsToTime(seconds, noSeconds, notAbbreviated, maxCount, roundUp)
local time = "";
local count = 0;
local tempTime;
seconds = roundUp and math.ceil(seconds) or math.floor(seconds);
maxCount = maxCount or 2;
-- When limited to a single term, use a higher threshold of 1.5 min/hr/day.
-- If there are at least 2 terms, the higher threshold is unnecessary.
local threshold = maxCount > 1 and 1.0 or 1.5
if ( seconds >= SECONDS_PER_DAY * threshold ) then
count = count + 1;
if ( count == maxCount and roundUp ) then
tempTime = math.ceil(seconds / SECONDS_PER_DAY);
else
tempTime = math.floor(seconds / SECONDS_PER_DAY);
end
if ( notAbbreviated ) then
time = L["D_DAYS"]:format(tempTime);
else
time = L["DAYS_ABBR"]:format(tempTime);
end
seconds = seconds % SECONDS_PER_DAY;
end
if ( count < maxCount and seconds >= SECONDS_PER_HOUR * threshold ) then
count = count + 1;
if ( time ~= "" ) then
time = time..L["TIME_UNIT_DELIMITER"];
end
if ( count == maxCount and roundUp ) then
tempTime = math.ceil(seconds / SECONDS_PER_HOUR);
else
tempTime = math.floor(seconds / SECONDS_PER_HOUR);
end
if ( notAbbreviated ) then
time = time..L["D_HOURS"]:format(tempTime);
else
time = time..L["HOURS_ABBR"]:format(tempTime);
end
seconds = seconds % SECONDS_PER_HOUR;
end
if ( count < maxCount and seconds >= SECONDS_PER_MIN * threshold ) then
count = count + 1;
if ( time ~= "" ) then
time = time..L["TIME_UNIT_DELIMITER"];
end
if ( count == maxCount and roundUp ) then
tempTime = math.ceil(seconds / SECONDS_PER_MIN);
else
tempTime = math.floor(seconds / SECONDS_PER_MIN);
end
if ( notAbbreviated ) then
time = time..L["D_MINUTES"]:format(tempTime);
else
time = time..L["MINUTES_ABBR"]:format(tempTime);
end
seconds = seconds % SECONDS_PER_MIN;
end
if ( count < maxCount and seconds > 0 and not noSeconds ) then
if ( time ~= "" ) then
time = time..L["TIME_UNIT_DELIMITER"];
end
if ( notAbbreviated ) then
time = time..L["D_SECONDS"]:format(seconds);
else
time = time..L["SECONDS_ABBR"]:format(seconds);
end
end
return time;
end
-- Deprecated. See SecondsFormatter for intended replacement
function MinutesToTime(mins, hideDays)
local time = "";
local count = 0;
local tempTime;
-- only show days if hideDays is false
if ( mins > 1440 and not hideDays ) then
tempTime = floor(mins / 1440);
time = L["TIME_UNIT_DELIMITER"] .. format(L["DAYS_ABBR"], tempTime);
mins = mins % 1440;
count = count + 1;
end
if ( mins > 60 ) then
tempTime = floor(mins / 60);
time = time .. L["TIME_UNIT_DELIMITER"] .. format(L["HOURS_ABBR"], tempTime);
mins = mins % 60;
count = count + 1;
end
if ( count < 2 ) then
tempTime = mins;
time = time .. L["TIME_UNIT_DELIMITER"] .. format(L["MINUTES_ABBR"], tempTime);
count = count + 1;
end
return time;
end
-- Deprecated. See SecondsFormatter for intended replacement
function SecondsToTimeAbbrev(seconds, thresholdOverride)
local tempTime;
local threshold = 1.5;
if thresholdOverride then
threshold = thresholdOverride;
end
if ( seconds >= SECONDS_PER_DAY * threshold ) then
tempTime = ceil(seconds / SECONDS_PER_DAY);
return L["DAY_ONELETTER_ABBR"], tempTime;
end
if ( seconds >= SECONDS_PER_HOUR * threshold ) then
tempTime = ceil(seconds / SECONDS_PER_HOUR);
return L["HOUR_ONELETTER_ABBR"], tempTime;
end
if ( seconds >= SECONDS_PER_MIN * threshold ) then
tempTime = ceil(seconds / SECONDS_PER_MIN);
return L["MINUTE_ONELETTER_ABBR"], tempTime;
end
return L["SECOND_ONELETTER_ABBR"], seconds;
end
function FormatShortDate(day, month, year)
local LOCALE_enGB = (GetLocale() == "enUS") or (GetLocale() == "enGB")
if (year) then
if (LOCALE_enGB) then
return L["SHORTDATE_EU"]:format(day, month, year);
else
return L["SHORTDATE"]:format(day, month, year);
end
else
if (LOCALE_enGB) then
return L["SHORTDATENOYEAR_EU"]:format(day, month);
else
return L["SHORTDATENOYEAR"]:format(day, month);
end
end
end
function BreakUpLargeNumbers(value)
local retString = "";
if ( value < 1000 ) then
if ( (value - math.floor(value)) == 0) then
return value;
end
local decimal = (math.floor(value*100));
retString = string.sub(decimal, 1, -3);
retString = retString..L["DECIMAL_SEPERATOR"];
retString = retString..string.sub(decimal, -2);
return retString;
end
value = math.floor(value);
retString = value;
return retString;
end
function AbbreviateLargeNumbers(value)
local strLen = strlen(value);
local retString = value;
if ( strLen > 8 ) then
retString = string.sub(value, 1, -7)..L["SECOND_NUMBER_CAP"];
elseif ( strLen > 5 ) then
retString = string.sub(value, 1, -4)..L["FIRST_NUMBER_CAP"];
elseif (strLen > 3 ) then
retString = BreakUpLargeNumbers(value);
end
return retString;
end
NUMBER_ABBREVIATION_DATA = {
-- Order these from largest to smallest
-- (significandDivisor and fractionDivisor should multiply to be equal to breakpoint)
{ breakpoint = 10000000000000, abbreviation = L["FOURTH_NUMBER_CAP_NO_SPACE"], significandDivisor = 1000000000000, fractionDivisor = 1 },
{ breakpoint = 1000000000000, abbreviation = L["FOURTH_NUMBER_CAP_NO_SPACE"], significandDivisor = 100000000000, fractionDivisor = 10 },
{ breakpoint = 10000000000, abbreviation = L["THIRD_NUMBER_CAP_NO_SPACE"], significandDivisor = 1000000000, fractionDivisor = 1 },
{ breakpoint = 1000000000, abbreviation = L["THIRD_NUMBER_CAP_NO_SPACE"], significandDivisor = 100000000, fractionDivisor = 10 },
{ breakpoint = 10000000, abbreviation = L["SECOND_NUMBER_CAP_NO_SPACE"], significandDivisor = 1000000, fractionDivisor = 1 },
{ breakpoint = 1000000, abbreviation = L["SECOND_NUMBER_CAP_NO_SPACE"], significandDivisor = 100000, fractionDivisor = 10 },
{ breakpoint = 10000, abbreviation = L["FIRST_NUMBER_CAP_NO_SPACE"], significandDivisor = 1000, fractionDivisor = 1 },
{ breakpoint = 1000, abbreviation = L["FIRST_NUMBER_CAP_NO_SPACE"], significandDivisor = 100, fractionDivisor = 10 },
}
function AbbreviateNumbers(value)
for i, data in ipairs(NUMBER_ABBREVIATION_DATA) do
if value >= data.breakpoint then
local finalValue = math.floor(value / data.significandDivisor) / data.fractionDivisor;
return finalValue .. data.abbreviation;
end
end
return tostring(value);
end
+78 -13
View File
@@ -80,7 +80,8 @@ Private.group_hybrid_sort_types = {
Private.time_format_types = {
[0] = L["WeakAuras Built-In (63:42 | 3:07 | 10 | 2.4)"],
[1] = L["Blizzard (2h | 3m | 10s | 2.4)"],
[1] = L["Old Blizzard (2h | 3m | 10s | 2.4)"],
[2] = L["Modern Blizzard (1h 3m | 3m 7s | 10s | 2.4)"],
}
Private.time_precision_types = {
@@ -98,7 +99,8 @@ Private.precision_types = {
Private.big_number_types = {
["AbbreviateNumbers"] = L["AbbreviateNumbers (Blizzard)"],
["AbbreviateLargeNumbers"] = L["AbbreviateLargeNumbers (Blizzard)"]
["AbbreviateLargeNumbers"] = L["AbbreviateLargeNumbers (Blizzard)"],
["BreakUpLargeNumbers"] = L["BreakUpLargeNumbers (Blizzard)"],
}
Private.big_number_types_with_disable = CopyTable(Private.big_number_types)
@@ -122,8 +124,70 @@ Private.unit_realm_name_types = {
always = L["Always include realm"]
}
local timeFormatter = {}
WeakAuras.Mixin(timeFormatter, SecondsFormatterMixin)
timeFormatter:Init(0, SecondsFormatter.Abbreviation.OneLetter)
-- The default time formatter adds a space between the value and the unit
-- While there is a API to strip it, that API does not work on all locales, e.g. german
-- Thus, copy the interval descriptions, strip the whitespace from them
-- and hack the timeFormatter to use our interval descriptions
local timeFormatIntervalDescriptionFixed = {}
timeFormatIntervalDescriptionFixed = CopyTable(SecondsFormatter.IntervalDescription)
for i, interval in ipairs(timeFormatIntervalDescriptionFixed) do
interval.formatString = CopyTable(SecondsFormatter.IntervalDescription[i].formatString)
for j, formatString in ipairs(interval.formatString) do
interval.formatString[j] = formatString:gsub(" ", "")
end
end
timeFormatter.GetIntervalDescription = function(self, interval)
return timeFormatIntervalDescriptionFixed[interval]
end
timeFormatter.GetMaxInterval = function(self)
return #timeFormatIntervalDescriptionFixed
end
local AbbreviateNumbers = AbbreviateNumbers
local gameLocale = GetLocale()
if gameLocale == "koKR" or gameLocale == "zhCN" or gameLocale == "zhTW" then
-- Work around https://github.com/Stanzilla/WoWUIBugs/issues/515
--
local NUMBER_ABBREVIATION_DATA_FIXED={
[1]={
breakpoint = 10000 * 10000,
significandDivisor = 10000 * 10000,
abbreviation = L["SECOND_NUMBER_CAP_NO_SPACE"],
fractionDivisor = 1
},
[2]={
breakpoint = 1000 * 10000,
significandDivisor = 1000 * 10000,
abbreviation = L["SECOND_NUMBER_CAP_NO_SPACE"],
fractionDivisor = 10
},
[3]={
breakpoint = 10000,
significandDivisor = 1000,
abbreviation = L["FIRST_NUMBER_CAP_NO_SPACE"],
fractionDivisor = 10
}
}
AbbreviateNumbers = function(value)
for i, data in ipairs(NUMBER_ABBREVIATION_DATA_FIXED) do
if value >= data.breakpoint then
local finalValue = math.floor(value / data.significandDivisor) / data.fractionDivisor;
return finalValue .. data.abbreviation;
end
end
return tostring(value);
end
end
local simpleFormatters = {
--[[AbbreviateNumbers = function(value)
AbbreviateNumbers = function(value)
if type(value) == "string" then value = tonumber(value) end
return (type(value) == "number") and AbbreviateNumbers(value) or value
end,
@@ -134,7 +198,7 @@ local simpleFormatters = {
BreakUpLargeNumbers = function(value)
if type(value) == "string" then value = tonumber(value) end
return (type(value) == "number") and BreakUpLargeNumbers(value) or value
end,]]
end,
floor = function(value)
if type(value) == "string" then value = tonumber(value) end
return (type(value) == "number") and floor(value) or value
@@ -164,10 +228,10 @@ local simpleFormatters = {
-- Remove the space between the value and unit
return fmt:gsub(" ", ""):format(time)
end,
--[[ Modern Blizzard
[2] = WeakAuras.IsRetail() and function(value)
-- Modern Blizzard
[2] = function(value)
return timeFormatter:Format(value)
end,]]
end,
-- Fixed built-in formatter
[99] = function(value)
if type(value) == "string" then value = tonumber(value) end
@@ -257,7 +321,7 @@ Private.format_types = {
addOption(symbol .. "_time_legacy_floor", {
type = "toggle",
name = L["Use Legacy floor rounding"],
desc = L["Enables (incorrect) round down of seconds, which was the previous default behaviour."],
desc = L["Enables (incorrect) round down of seconds, which was the previous default behavior."],
width = WeakAuras.normalWidth,
hidden = hidden,
disabled = function() return get(symbol .. "_time_format", 0) ~= 0 end
@@ -277,7 +341,6 @@ Private.format_types = {
end
local mainFormater = simpleFormatters.time[format]
local modRateProperty = {}
local timePointProperty = {}
-- For the mod rate support, we need to know which state member is the modRate, as
@@ -365,7 +428,6 @@ Private.format_types = {
end
end
},
--[[
Money = {
display = L["Money"],
AddOptions = function(symbol, hidden, addOption)
@@ -428,22 +490,23 @@ Private.format_types = {
values = Private.big_number_types,
hidden = hidden
})
end,
addOption(symbol .. "_big_number_space", {
type = "description",
name = "",
width = WeakAuras.normalWidth,
hidden = hidden
})
end,
CreateFormatter = function(symbol, get)
local format = get(symbol .. "_big_number_format", "AbbreviateNumbers")
if (format == "AbbreviateNumbers") then
return simpleFormatters.AbbreviateNumbers
elseif (format == "BreakUpLargeNumbers") then
return simpleFormatters.BreakUpLargeNumbers
end
return simpleFormatters.AbbreviateLargeNumbers
end
},
]]
Number = {
display = L["Number"],
AddOptions = function(symbol, hidden, addOption, get)
@@ -2229,9 +2292,11 @@ Private.TocToExpansion = {
[7] = L["Legion"],
[8] = L["Battle for Azeroth"],
[9] = L["Shadowlands"],
[10] = L["Dragonflight"]
[10] = L["Dragonflight"],
[11] = L["The War Within"]
}
Private.group_types = {
solo = L["Not in Group"],
group = L["In Party"],
+1
View File
@@ -26,6 +26,7 @@ Pools.lua
embeds.xml
Init.lua
locales.xml
TimeUtil.lua
ArchiveTypes\Repository.lua
DefaultOptions.lua