יחידה:טווח זמנים: הבדלים בין גרסאות בדף
הפיכת בדיקת השוואת תאריך הסיום ל"הווה" ללולאה כדי להמנע מתמיכה בהכנסה חלקית של הפרמטר. |
מ 7 גרסאות של הדף wikipedia:he:יחידה:טווח_זמנים יובאו |
||
| (10 גרסאות ביניים של 6 משתמשים אינן מוצגות) | |||
| שורה 73: | שורה 73: | ||
local ongoingEvent = defaultOngoingEvent | local ongoingEvent = defaultOngoingEvent | ||
local endDateOngoingEvent = args['הווה'] | local endDateOngoingEvent = args['הווה'] | ||
local presentText = args['טקסט הווה'] | |||
local diffFormat = 'auto' -- TODO: better handling for different scales | local diffFormat = 'auto' -- TODO: better handling for different scales | ||
| שורה 79: | שורה 80: | ||
-- set default ongoingEvent as false | -- set default ongoingEvent as false | ||
ongoingEvent = false | ongoingEvent = false | ||
for v in string.gmatch(endDateOngoingEvent, "[^, | for v in string.gmatch(endDateOngoingEvent, "[^,]+") do | ||
if v == endDate then | if v:match('^%s*(.-)%s*$') == endDate then | ||
-- set as true if end date specific that match endDateOngoingEvent | -- set as true if end date specific that match endDateOngoingEvent | ||
ongoingEvent = true | ongoingEvent = true | ||
if presentText then endDate=presentText end | |||
end | end | ||
end | end | ||
| שורה 103: | שורה 105: | ||
elseif startDate ~= nil and (endDate==nil or (ongoingEvent and endDate~=nil)) then | elseif startDate ~= nil and (endDate==nil or (ongoingEvent and endDate~=nil)) then | ||
if ongoingEvent then | if ongoingEvent then | ||
dateFormat = '%s–%s' | |||
if mw.ustring.match(startDate, ' ') or (endDate and mw.ustring.match(endDate, ' ')) then | |||
dateFormat = '%s – %s' | |||
end | |||
res = mw.ustring.format(dateFormat, startDate, endDate or 'הווה') | |||
-- try to fallback to automatic duration if duration is not available | -- try to fallback to automatic duration if duration is not available | ||
if showTimeDiff == 'כן' and duration==nil then | if showTimeDiff == 'כן' and duration==nil then | ||
| שורה 113: | שורה 119: | ||
end | end | ||
elseif startDate~=nil and endDate~=nil then | elseif startDate~=nil and endDate~=nil then | ||
dateFormat = '%s–%s' | |||
if mw.ustring.match(startDate, ' ') or mw.ustring.match(endDate, ' ') then | |||
dateFormat = '%s – %s' | |||
end | |||
res = mw.ustring.format(dateFormat, startDate, endDate) | |||
if showTimeDiff == 'כן' and duration==nil then | if showTimeDiff == 'כן' and duration==nil then | ||
local success, automaicDuration = pcall(Date.parseDateRange, res, diffFormat, true) | local success, automaicDuration = pcall(Date.parseDateRange, res, diffFormat, true) | ||
| שורה 122: | שורה 132: | ||
-- append the duration | -- append the duration | ||
if showTimeDiff == 'כן' and duration~=nil and duration~='' then | if showTimeDiff == 'כן' and duration~=nil and duration~='' and res~=nil then | ||
res = mw.ustring.format(dateRangeDiffFormat, res, duration) | res = mw.ustring.format(dateRangeDiffFormat, res, duration) | ||
end | end | ||