- Share this text:
Untitled - posted by guest on 28th February 2020 10:38:40 PM
----------------------------------------------------------------------------------------------------
---------------------------------------------| E T A |--------------------------------------------
----------------------------------------------------------------------------------------------------
function eta(time)
local head = L"Sie erreichen Ihr Ziel um"
local article
local min
local tod -- time of day
local hour = time.hour
if hour > 24 then hour = hour - 24 end
if hour == 1 then article = L""
else article = L"? " end
if hour == 0 then head = L"Sie erreichen Ihr Ziel" end
if hour == 0 then hour = L"um null" end
if hour == 12 then head = L"Sie erreichen Ihr Ziel" end
if hour == 12 then hour = L"Um zwölf" end
if time.min ~= 0 then min = L"und"..towstring(time.min)..L"minuten."
else min = L"" end
if time.hour < 5 then tod = L""
elseif time.hour < 12 then tod = L""
elseif time.hour < 20 then tod = L""
elseif time.hour < 24 then tod = L""
else tod = L"" end
return head..towstring(hour)..min..tod
end
--- korekturen VICEWANDEL 14.01.2020 ---
local time_patternts = {L" eine", L" zwei"}
function format_timeto(timeto)
local hour, min
if type(timeto) == "wstring" then
local hour_ = wstring.sub(timeto,1,-4)
local min_ = wstring.sub(timeto,-2,-1)
hour = tonumber(hour_)
min = tonumber(min_)
else
local _, _, hour_, min_ = wstring.find(Format_Timespan(timeto, ETimespanFormat.HrMinRounded), L"(%d+):(%d+)")
hour, min = tonumber(hour_), tonumber(min_)
end
local function time_to_phrase(number, hm)
local sentence = L""
if number ~= 0 then
local number_10 = number % 10
if number_10 == 1 and number ~= 11 then
sentence = hm == "h" and L" stunde " or L" minute "
elseif number_10 > 4 or number_10 == 0 or (number > 10 and number < 20) then
sentence = hm == "h" and L" stunden " or L" minuten "
else
sentence = hm == "h" and L" stunde " or L" minute "
end
sentence = (((hm=="m")
and(number_10 == 1 or number_10 == 2)
and number ~= 11 and number ~= 12)
and((number - number_10)
and format_numbers2text(number - number_10) or L"") .. time_patternts[number_10]
or format_numbers2text(number)) .. sentence
end
return sentence
end
--- korekturen "hours" и "mins" от VICEWANDEL 14.01.2020 ---
local time_text = time_to_phrase(hour, "h") .. time_to_phrase(min, "m")
if time_text == L"" then
time_text = L"weniger als eine minute"
end
return time_text
end