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. | 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" | elseif flag == "future" or flag == "current" or flag == "former" then | ||
self:setPeriod(flag) | |||
self | |||
return true | return true | ||
elseif flag == "" then | elseif flag == "" then | ||
949行目: | 967行目: | ||
local endTimeD = nil | local endTimeD = nil | ||
if self. | 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. | if self.periods[1] then | ||
-- future | -- future | ||
if startTimeY | if startTimeY and datePrecedesDate(now['year'], now['month'], now['day'], startTimeY, startTimeM, startTimeD) then | ||
return true | return true | ||
end | end | ||
end | |||
if self.periods[2] then | |||
-- current | -- current | ||
if (startTimeY | if (startTimeY == nil or not datePrecedesDate(now['year'], now['month'], now['day'], startTimeY, startTimeM, startTimeD)) and | ||
(endTimeY | (endTimeY == nil or datePrecedesDate(now['year'], now['month'], now['day'], endTimeY, endTimeM, endTimeD)) then | ||
return true | return true | ||
end | end | ||
end | |||
if self.periods[3] then | |||
-- former | -- former | ||
if endTimeY | if endTimeY and not datePrecedesDate(now['year'], now['month'], now['day'], endTimeY, endTimeM, endTimeD) then | ||
return true | return true | ||
end | end | ||
end | end | ||
return false | |||
end | end | ||