「モジュール:Wd」の版間の差分

en:Module:Wd 2017年2月10日 (金) 11:09(UTC)より
template>K-iczn
(en:Module:Wd 2017年2月9日 (木) 20:48(UTC)より)
template>K-iczn
(en:Module:Wd 2017年2月10日 (金) 11:09(UTC)より)
74行目: 74行目:
cfg.flagRank = false
cfg.flagRank = false
cfg.period = 0
cfg.periods = {true, true, true}  -- future = true, current = true, former = true
cfg.flagPeriod = false
cfg.mdyDate = false
cfg.mdyDate = false
843行目: 845行目:
self.ranks[rankPos] = true
self.ranks[rankPos] = true
end
end
end
function Config:setPeriod(period)
local periodPos
if period == "future" then
periodPos = 1
elseif period == "current" then
periodPos = 2
elseif period == "former" then
periodPos = 3
else
return
end
-- one of the period flags was given, check if another one was given before
if not self.flagPeriod then
self.periods = {false, false, false}  -- no other period flag given before, so unset periods
self.flagPeriod = true                -- mark that a period flag was given
end
self.periods[periodPos] = true
end
end


873行目: 897行目:
self:setRank(flag)
self:setRank(flag)
return true
return true
elseif flag == "future" then
elseif flag == "future" or flag == "current" or flag == "former" then
self.period = 1
self:setPeriod(flag)
return true
elseif flag == "current" then
self.period = 2
return true
elseif flag == "former" then
self.period = 3
return true
return true
elseif flag == "" then
elseif flag == "" then
949行目: 967行目:
local endTimeD = nil
local endTimeD = nil
if self.period == 0 then
if self.periods[1] and self.periods[2] and self.periods[3] then
-- any time
-- any time
return true
return true
979行目: 997行目:
end
end
if self.period == 1 then
if self.periods[1] then
-- future
-- future
if startTimeY == nil or not datePrecedesDate(now['year'], now['month'], now['day'], startTimeY, startTimeM, startTimeD) then
if startTimeY and datePrecedesDate(now['year'], now['month'], now['day'], startTimeY, startTimeM, startTimeD) then
return false
else
return true
return true
end
end
elseif self.period == 2 then
end
if self.periods[2] then
-- current
-- current
if (startTimeY ~= nil and datePrecedesDate(now['year'], now['month'], now['day'], startTimeY, startTimeM, startTimeD)) or
if (startTimeY == nil or not datePrecedesDate(now['year'], now['month'], now['day'], startTimeY, startTimeM, startTimeD)) and
  (endTimeY ~= nil and not datePrecedesDate(now['year'], now['month'], now['day'], endTimeY, endTimeM, endTimeD)) then
  (endTimeY == nil or datePrecedesDate(now['year'], now['month'], now['day'], endTimeY, endTimeM, endTimeD)) then
    return false
else
  return true
  return true
end
end
elseif self.period == 3 then
end
if self.periods[3] then
-- former
-- former
if endTimeY == nil or datePrecedesDate(now['year'], now['month'], now['day'], endTimeY, endTimeM, endTimeD) then
if endTimeY and not datePrecedesDate(now['year'], now['month'], now['day'], endTimeY, endTimeM, endTimeD) then
return false
else
return true
return true
end
end
end
end
return false
end
end


匿名利用者