יחידה:טווח זמנים: הבדלים בין גרסאות בדף

מאין תקציר עריכה
מ 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 ongoingEvent = args['נמשך'] == 'כן'
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 ongoingEvent == false and endDateOngoingEvent~=nil and endDate~=nil then
ongoingEvent = (mw.ustring.find(endDateOngoingEvent, endDate, 1, true) ~= nil)
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
res = mw.ustring.format('%s – %s', startDate, endDate or 'הווה')
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
res = mw.ustring.format('%s – %s', startDate, endDate)
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