אונטערשייד צווישן ווערסיעס פון "יחידה:טווח זמנים"

אפדעיט
(אפדעיט)
(אפדעיט)
 
(7 מיטלסטע ווערסיעס פון איין אנדער באַניצער נישט געוויזן.)
שורה 1: שורה 1:
local Date = require('Module:דאטום')
local Date = require('Module:דאטום')
local HDate = require('Module:אידישע דאטום')
local Arguments = require( "Module:Arguments" )
local Arguments = require( "Module:Arguments" )
--[[
Assuming a string representng a date is passed, this function tries to determine
whether the date is Hebrew
]]
local function isHDate(str)
  -- quick heuristic: date without numeric digit is probably hebrew
  if string.match(str, "%d") then
    return false
  else
    return true
  end
end


local function WikidataSimpleFill(parameter, entityId, property)  
local function WikidataSimpleFill(parameter, entityId, property)  
שורה 38: שורה 52:
local pointInTime = args['נקודת זמן']
local pointInTime = args['נקודת זמן']
local startDate = args['תאריך התחלה']
local startDate = args['תאריך התחלה']
local HStartDate
if startDate ~= nil and isHDate(startDate) then
HStartDate = startDate
local success, sepcDate = pcall(HDate.pick, mw.getCurrentFrame():newChild{ args = {hebrew=startDate, world='', exact='כן' } })
if success and sepcDate ~= '' then
    startDate = sepcDate
end
end
local endDate = args['תאריך סיום']
local endDate = args['תאריך סיום']
local HEndDate
if endDate ~= nil and isHDate(endDate) then
HEndDate = endDate
local success, sepcDate = pcall(HDate.pick, mw.getCurrentFrame():newChild{ args = {hebrew=endDate, world='', exact='כן' } })
if success and sepcDate ~= '' then
    endDate = sepcDate
end
end
local wikidataStartDate = args['תאריך התחלה-ויקינתונים'] or 'P580'
local wikidataStartDate = args['תאריך התחלה-ויקינתונים'] or 'P580'
שורה 47: שורה 77:
-- text to show if we have only end date. Example: "Last even - %s" where %s is time. nil - will not show end date
-- text to show if we have only end date. Example: "Last even - %s" where %s is time. nil - will not show end date
local onlyEndDateText = args['טקסט סיום']
local onlyEndDateText = args['טקסט סיום']
-- text to show if we have only start date. Example: "First even - %s" where %s is time. nil - will not show end date
local onlyStartDateText = args['טקסט התחלה']
 
local duration = args['משך'] --P2047
local duration = args['משך'] --P2047
-- Whether to show time diff between start and end day when applicable. Example: כן.
-- Whether to show time diff between start and end day when applicable. Example: כן.
שורה 78: שורה 110:
end
end


if endDate == '' or endDate == nil and wikidataEndDateLimit~=nil and wikidataEndDateLimit~='' then
-- if only start date available, we will add prefix prefixStartOnly otherwise will bound the end
if onlyStartDateText==nil and (endDate == '' or endDate == nil) and wikidataEndDateLimit~=nil and wikidataEndDateLimit~='' then
-- fallback
-- fallback
endDate, usingWikidataEndDate = WikidataSimpleFill(endDate, entityId, wikidataEndDateLimit )
endDate, usingWikidataEndDate = WikidataSimpleFill(endDate, entityId, wikidataEndDateLimit )
שורה 141: שורה 174:
end
end
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 onlyStartDateText then
dateFormat = '%s–%s'
res = mw.ustring.format(onlyStartDateText, startDate)
if mw.ustring.match(startDate, ' ') or (endDate and mw.ustring.match(endDate, ' ')) then
else
dateFormat = '%s – %s'
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, HStartDate or startDate, HEndDate or endDate or 'הווה')
-- try to fallback to automatic duration if duration is not available
if showTimeDiff == 'כן' and duration==nil then
local success, automaicDuration = pcall(Date.parseDateRange, startDate, diffFormat, true)
if success then duration = automaicDuration end
end
else
res = HStartDate or startDate
end
end
res = mw.ustring.format(dateFormat, startDate, endDate or 'הווה')
-- try to fallback to automatic duration if duration is not available
if showTimeDiff == 'כן' and duration==nil then
local success, automaicDuration = pcall(Date.parseDateRange, startDate, diffFormat, true)
if success then duration = automaicDuration end
end
else
res = startDate
end
end
elseif startDate~=nil and endDate~=nil  then
elseif startDate~=nil and endDate~=nil  then
שורה 160: שורה 197:
dateFormat = '%s – %s'
dateFormat = '%s – %s'
end
end
res = mw.ustring.format(dateFormat, startDate, endDate)
res = mw.ustring.format(dateFormat, HStartDate or startDate, HEndDate or 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, startDate .. '-' .. endDate, diffFormat, true)
if success then duration = automaicDuration end
if success then duration = automaicDuration end
end
end