Modul:TimestampedTable
Sari la navigare
Sari la căutare
Documentația acestui modul poate fi creată la Modul:TimestampedTable/doc
Eroare în script: Lua error: Cannot create process: proc_open(/dev/null): Failed to open stream: Operation not permitted
local DateUtils = require('Modul:DateUtils')
local p = {}
local function getTimestampedValueFromArray(arr, ts)
local tsDate = type(ts) == 'string' and DateUtils.parseDate(ts) or type(ts) == 'table' and ts
if not tsDate then tsDate = nil end
local closestDate = nil
local closestDateLabel = nil
for k,v in pairs(arr) do
local crtStartDate = k == '_' and {year=-3000, precision=9} or DateUtils.parseDate(k)
if (nil == tsDate or (tsDate and DateUtils.compare(crtStartDate, tsDate) <= 0)) and
(nil == closestDate or DateUtils.compare(crtStartDate, closestDate) > 0) then
closestDate = crtStartDate
closestDateLabel = k
end
end
return arr[closestDateLabel]
end
p.getValueByTimestamp = getTimestampedValueFromArray
return p