יחידה:טווח זמנים: הבדלים בין גרסאות בדף
מאין תקציר עריכה |
מ 7 גרסאות של הדף wikipedia:he:יחידה:טווח_זמנים יובאו |
||
| (13 גרסאות ביניים של 7 משתמשים אינן מוצגות) | |||
| שורה 70: | שורה 70: | ||
-- Whether the event still continues. this will show <START>-present. Example: כן | -- Whether the event still continues. this will show <START>-present. Example: כן | ||
local | local defaultOngoingEvent = args['נמשך'] == 'כן' | ||
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 | ||
if | |||
if endDate~=nil and endDate~='' then | |||
if endDateOngoingEvent~=nil then | |||
-- set default ongoingEvent as false | |||
ongoingEvent = false | |||
for v in string.gmatch(endDateOngoingEvent, "[^,]+") do | |||
if v:match('^%s*(.-)%s*$') == endDate then | |||
-- set as true if end date specific that match endDateOngoingEvent | |||
ongoingEvent = true | |||
if presentText then endDate=presentText end | |||
end | |||
end | |||
else | |||
-- explicity end date was specified, hence it is not ongoing | |||
ongoingEvent = false | |||
end | |||
end | end | ||
-- simple case of single point in time | -- simple case of single point in time | ||
if pointInTime~=nil or startDate==endDate then | if pointInTime~=nil or startDate==endDate then | ||
| שורה 88: | שורה 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 | ||
| שורה 98: | שורה 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) | ||
| שורה 107: | שורה 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 | ||