![]() |
VOOZH | about |
This module implements {{CompareVersion}}.
localp={} functionp.main(frame) localargs=require('Module:Arguments').getArgs(frame,{ wrappers='Template:CompareVersion/helper' }) returnp.second(args) end functionsplit(str) localarray={} localcurr=1 locali=1 localsection="" whilestring.sub(str,i,i)~=""do ifstring.sub(str,i,i)=="."then array[curr]=tonumber(section)or-1 section="" curr=curr+1 else section=section..string.sub(str,i,i) end i=i+1 end array[curr]=tonumber(section)or-1 returnarray end functionp.second(args) localuser_ver=split(args[1]or"") localcurr_ver=split(args[2]or"") ifuser_ver==""orcurr_ver==""then return"" end locali=1 localresult="1" whileuser_ver[i]~=nilandcurr_ver[i]~=nildo ifuser_ver[i]==-1orcurr_ver[i]==-1then result="3" break end ifcurr_ver[i]>user_ver[i]then result="2" break end ifuser_ver[i]>curr_ver[i]then result="3" break end i=i+1 end ifresult=="1"anduser_ver[i]~=nilthen result="3" end ifresult=="3"then return"" else return"true" end end returnp