Z26036

{
    "Z1K1": "Z2",
    "Z2K1": {
        "Z1K1": "Z6",
        "Z6K1": "Z26036"
    },
    "Z2K2": {
        "Z1K1": "Z14",
        "Z14K1": "Z26033",
        "Z14K3": {
            "Z1K1": "Z16",
            "Z16K1": "Z600",
            "Z16K2": "function Z26033( Z26033K1 ) {\n\tvar input=Z26033K1;\n\tconst separators=[\" \",\"\\t\",\"/\",\"\\\\\",\"'\",'\"',\"|\"];\n\tconst prefOptions=[\"mdye\",\"mdey\",\"yemd\",\"eymd\",\"dmye\",\"dmey\",\"yedm\",\"eydm\"];\n\n\tfunction languageSpecificOptions(){\n\t\tdefineLiterals({\n\t\t\tJA:0n,\n\t\t\tFE:1n,\n\t\t\tMR:2n,\n\t\t\tAP:3n,\n\t\t\tMY:4n,\n\t\t\tJN:5n,\n\t\t\tJL:6n,\n\t\t\tAU:7n,\n\t\t\tSE:8n,\n\t\t\tOC:9n,\n\t\t\tNV:10n,\n\t\t\tDE:11n,\n\t\t\tjanuary:0n,\n\t\t\tfebruary:1n,\n\t\t\tmarch:2n,\n\t\t\tapril:3n,\n\t\t\tmay:4n,\n\t\t\tjune:5n,\n\t\t\tjuly:6n,\n\t\t\taugust:7n,\n\t\t\tseptember:8n,\n\t\t\toctober:9n,\n\t\t\tnovember:10n,\n\t\t\tdecember:11n\n\t\t},MONTH);\n\t\tdefineLiterals({\n\t\t\ti:0n,\n\t\t\tii:1n,\n\t\t\tiii:2n,\n\t\t\tiv:3n,\n\t\t\tiiii:3n,\n\t\t\tv:4n,\n\t\t\tvi:5n,\n\t\t\tvii:6n,\n\t\t\tviii:7n,\n\t\t\tviiii:8n,\n\t\t\tix:8n,\n\t\t\tx:9n,\n\t\t\txi:10n,\n\t\t\txii:11n\n\t\t},MONTH,NORMAL);\n\t\tdefineLiterals({\n\t\t\tad:1n,\n\t\t\tbc:-1n,\n\t\t\tbce:-1n,\n\t\t\tce:1n,\n\t\t},ERA,LETTER_BY_LETTER);\n\t\tdefineLiterals({\n\t\t\t\"pɔi anabi Yisa dɔɣam\":-1n,\n\t\t\t\"ti zaamani\":1n,\n\t\t\t\"Anabi Yisa kpibu nyaaga\":1n\n\t\t},ERA);\n\t\t//forced as days\n\t\tdefineLiterals({\n\t\t\tdahinyini: 1n,\n\t\t\tdabaayi: 2n,\n\t\t\tdabaata: 3n,\n\t\t\tdabaanahi: 4n,\n\t\t\tdabaanu: 5n,\n\t\t\tdabaayɔbu: 6n,\n\t\t\tdabaapɔin: 7n,\n\t\t\tdabaanii: 8n,\n\t\t\tdabaawɔi: 9n,\n\t\t},DAY,NORMAL);\n\t\t//days or years\n\t\tdefineLiterals({\n\t\t\tyini:1n,\n\t\t\tayi:2n,\n\t\t\tata:3n,\n\t\t\tanahi:4n,\n\t\t\tanu:5n,\n\t\t\tayobu:6n,\n\t\t\tapɔi:7n,\n\t\t\tanii:8n,\n\t\t\tawei:9n,\n\t\t\t\"Pia\": 10n,\n\t\t\t\"piniyini\": 11n,\n\t\t\t\"pia ni yini\": 11n,\n\t\t\t\"pinaayi\": 12n,\n\t\t\t\"pia ni ayi\": 12n,\n\t\t\t\"pin ayi\": 12n,\n\t\t\t\"pinaata\": 13n,\n\t\t\t\"pin ata\": 13n,\n\t\t\t\"pia ni ata\": 13n,\n\t\t\t\"pinaanahi\": 14n,\n\t\t\t\"pia ni anahi\": 14n,\n\t\t\t\"pin anahi\": 14n,\n\t\t\t\"pinaanu\": 15n,\n\t\t\t\"pia ni anu\": 15n,\n\t\t\t\"pin anu\": 15n,\n\t\t\t\"pinaayobu\": 16n,\n\t\t\t\"pia ni ayobu\": 16n,\n\t\t\t\"pin ayobu\": 16n,\n\t\t\t\"pinaapɔin\": 17n,\n\t\t\t\"pia ni apɔi\": 17n,\n\t\t\t\"pin apɔi\": 17n,\n\t\t\t\"pishiayika\": 18n,\n\t\t\t\"pishi ayi ka\": 18n,\n\t\t\t\"pisiyinika\": 19n,\n\t\t\t\"pishi yini ka\": 19n,\n\t\t\t\"pishi\": 20n,\n\t\t\t\"pishi ni yini\": 21n,\n\t\t\t\"pishi ni ayi\": 22n,\n\t\t\t\"pishi ni ata\": 23n,\n\t\t\t\"Pishi ni anahi\": 24n,\n\t\t\t\"Pishi ni anu\": 25n,\n\t\t\t\"Pishi ni ayobu\": 26n,\n\t\t\t\"Pishi ni apɔin\": 27n,\n\t\t\t\"Pihita ayika\": 28n,\n\t\t\t\"Pihita ayi ka\": 28n,\n\t\t\t\"Pihitayinika\": 29n,\n\t\t\t\"Pihita yini ka\": 29n,\n\t\t\t\"pihita\": 30n,\n\t\t\t\"pihita ni yini\": 31n,\n\t\t},[DAY,YEAR],NORMAL);\n\t\tdefineConstraint([\"st\",\"nd\",\"rd\",\"th\"],DAY,AFTER);\t//forced after a day\n\t\tdefineConstraint([\"yuuni\"],YEAR, BEFORE_OR_AFTER);\t\t//forced before or after a year\n\t\tdefineConstraint([\"biɛɣu\"],DAY, BEFORE);\t\t\t//forced before a day\n\t\tdefineConstraint([\"dali\"],DAY, BEFORE_OR_AFTER);\t\t//forced before or after a day\n\t\n\t}\n\t\n\tconst delete_chain=[\"d\",\"m\",\"e\",\"y\"];\n\n\tconst DAY =0;\n\tconst MONTH=1;\n\tconst YEAR=2;\n\tconst ERA=3;\n\n\tconst BEFORE=10;\n\tconst AFTER=20;\n\tconst BEFORE_OR_AFTER=30;\n\n\tconst LENIENT=Symbol();\n\tconst NORMAL=Symbol();\n\tconst LETTER_BY_LETTER=Symbol();\n\n\tfunction defineLiterals(literals,meaning,compMode=LENIENT, forced=false){\n\t\tlet bestGuess=null;\n\t\tconst compFunc= compMode==LENIENT ? lenientComp : lessLenientComp;\n\t\tfor (let m in literals){\n\t\t\tlet target=m.split(\" \");\n\t\t\tlet ok=true;\n\t\t\tfor (let t=0; t\u003Ctarget.length; ++t){\n\t\t\t\tif (elements[iAtt+t]==undefined || !compFunc(elements[iAtt+t],target[t])){\n\t\t\t\t\tok=false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (ok){\n\t\t\t\tif (bestGuess == null || bestGuess[1]\u003Ctarget.length){\n\t\t\t\t\tbestGuess = [literals[m],target.length];\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (compMode==LETTER_BY_LETTER ){\n\t\t\t\tlet target=m.split(\"\");\n\t\t\t\ttarget.filter((l)=\u003El!=\" \");\n\t\t\t\tlet ok=true;\n\t\t\t\tfor (let t=0; t\u003Ctarget.length; ++t){\n\t\t\t\t\tif (elements[iAtt+t]==undefined || !compFunc(elements[iAtt+t],target[t])){\n\t\t\t\t\t\tok=false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (ok){\n\t\t\t\t\tif (bestGuess == null || bestGuess[1]\u003Ctarget.length){\n\t\t\t\t\t\tbestGuess = [literals[m],target.length];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t\tif (bestGuess==null){\n\t\t\treturn false;\n\t\t}\n\n\t\tif (typeof(meaning)==\"number\"){\n\t\t\tmeaning=[meaning];\n\t\t}\n\t\tfor (let m of meaning){\n\t\t\tswitch(m){\n\t\t\t\tcase 0: _day=bestGuess[0]; break;\n\t\t\t\tcase 1: _month=bestGuess[0]; break;\n\t\t\t\tcase 2: _year=bestGuess[0]; break;\n\t\t\t\tcase 3: _era=bestGuess[0]; break;\n\t\t\t}\n\t\t}\n\t\t_nSteps=bestGuess[1];\n\t\tif (forced){\n\t\t\t_forced=meaning;\n\t\t}\n\t\treturn true;\n\n\t}\n\tfunction defineLiteralFunction(f,meaning, forced=false){\n\t\tlet bestGuess=f(elements,iAtt);\n\t\tif (bestGuess==null){\n\t\t\treturn false;\n\t\t}\n\n\t\tif (typeof(meaning)==\"number\"){\n\t\t\tmeaning=[meaning];\n\t\t}\n\t\tfor (let m of meaning){\n\t\t\tswitch(m){\n\t\t\t\tcase 0: _day=bestGuess[0]; break;\n\t\t\t\tcase 1: _month=bestGuess[0]; break;\n\t\t\t\tcase 2: _year=bestGuess[0]; break;\n\t\t\t\tcase 3: _era=bestGuess[0]; break;\n\t\t\t}\n\t\t}\n\t\t_nSteps=bestGuess[1];\n\t\tif (forced){\n\t\t\t_forced=meaning;\n\t\t}\n\t\treturn true;\n\t}\n\tfunction defineConstraint(literals, meaning, position, compMode=NORMAL){\n\n\t\tlet bestGuess=null;\n\t\tconst compFunc= compMode==LENIENT ? lenientComp : lessLenientComp;\n\t\tfor (let m of literals){\n\t\t\tlet target=m.split(\" \");\n\t\t\tlet ok=true;\n\t\t\tfor (let t=0; t\u003Ctarget.length; ++t){\n\t\t\t\tif (elements[iAtt+t]==undefined || !compFunc(elements[iAtt+t],target[t])){\n\t\t\t\t\tok=false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (ok){\n\t\t\t\tif (bestGuess == null || bestGuess\u003Ctarget.length){\n\t\t\t\t\tbestGuess = target.length;\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t\tif (bestGuess==null){\n\t\t\treturn false;\n\t\t}\n\t\t\n\n\t\tif (typeof(meaning)==\"number\"){\n\t\t\tmeaning=[meaning];\n\t\t}\n\t\t\n\t\t_constraintsList.push({pos:possibilities.length, meaning:meaning, type: position});\n\n\t\t_nSteps=bestGuess;\n\t\t_isToBeIgnored=true;\n\t\treturn true;\n\t}\n\tfunction defineConstraintFunction(f,meaning,position){\n\n\t\tlet bestGuess=f(elements,iAtt);\n\t\tif (bestGuess==null){\n\t\t\treturn false;\n\t\t}\n\n\t\tif (typeof(meaning)==\"number\"){\n\t\t\tmeaning=[meaning];\n\t\t}\n\t\t_constraintsList.push({pos:possibilities.length, meaning:meaning, type: position});\n\t\t_nSteps=bestGuess;\n\t\t_isToBeIgnored=true;\n\t\treturn true;\n\t}\n\n\tfunction lenientComp(a,b){\n\t\ta=a.toLowerCase().replaceAll(/,|\\.|;|:/g,\"\");\n\t\tb=b.toLowerCase();\n\t\tif (a==\"\") return false;\n\t\treturn a==b.substring(0,a.length);\n\t}\n\n\tfunction lessLenientComp(a,b){\n\t\ta=a.toLowerCase().replaceAll(/,|\\.|;|:/g,\"\");\n\t\tb=b.toLowerCase();\n\t\tif (a==\"\") return false;\n\t\treturn a==b;\n\t}\n\n\tfunction extractNumber(s){\n\t\tlet res=/-?[0-9]+/.exec(s);\n\t\tif (res!=null){\n\t\t\treturn BigInt(res);\n\t\t}\n\t\treturn null;\n\t}\n\n\n\tfunction forceToYear(s){\n\t\tlet res=(/-?\\+?[0-9]+/.exec(s))?.[0];\n\t\tif (res==null){\n\t\t\treturn false;\n\t\t}\n\t\t//Wikifunctions.Debug(res);\n\t\tif (res.length\u003E2) return true;\n\t\tif (res[0]==\"-\" || res[0]==\"+\") return true;\n\t\treturn false;\n\t}\n\n\t\n\n\tinput=input.replaceAll(/-|—|‒|–|—|⸺|⸺/g,\"-\");\n\n\tvar isoRegex=/(\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d\\.\\d+)|(\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d)|(\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d)/;\n\tif (isoRegex.exec(input)){\n\t\tinput=input.split(\"T\")[0];\n\t\tvar list=input.split(/(?\u003C=.)-(?=.)/);\n\t\t//Wikifunctions.Debug(list);\n\t\treturn {\n\t\t\tK1: BigInt(list[0]),\n\t\t\tK2: list[1]-1,\n\t\t\tK3: list[2]\n\t\t};\n\t}\n\n\tvar elements=[\"\"];\n\tfor (let i=0; i\u003Cinput.length;){\n\t\tlet s=separators.find((v)=\u003E input.substring(i,i+v.length)==v);\n\t\tif (s!==undefined){\n\t\t\tif(elements[elements.length-1]!=\"\")\n\t\t\t\telements.push(\"\");\n\t\t\ti+=s.length;\n\t\t\tcontinue;\n\t\t}\n\t\telements[elements.length-1]+=input[i++];\n\t}\n\tif(elements[elements.length-1]==\"\") elements.pop();\n\n\n\tlet elSeparato=[];\n\tfor (let i=0; i\u003Celements.length; ++i){\n\t\tfor (let e of elements[i].matchAll(/((?:(?\u003C=^|\\s)[\\-\\+])?[0-9]+)?(?:\\-?([^0-9\\-]+))?/g)){\n\t\t\telSeparato.push(e.splice(1))\n\t\t}\n\t\t// elSeparato.push(/-?\\+?[0-9]+/.exec(elements[i]));\n\t\t// elSeparato.push(elements[i].split(/-?\\+?[0-9]+/));\n\t}\n\telSeparato=elSeparato.flat();\n\telements=elSeparato.filter((v)=\u003E(v!=null \u0026\u0026 v!=\"\"));\n\n\t// Wikifunctions.Debug(\"elements:\");\n\t// Wikifunctions.Debug(elements);\n\n\t//Order of possibilities: dmye\n\tvar possibilities=[];\n\n\tvar _constraintsList=[];\n\tvar _nSteps=1;\n\n\tfor(var iAtt=0; iAtt\u003Celements.length; iAtt+=_nSteps){\n\t\t_nSteps=1;\n\t\tlet n=extractNumber(elements[iAtt]);\n\t\tvar _day=null;\n\t\tvar _month=null;\n\t\tvar _year=null;\n\t\tvar _era=null;\n\t\tvar _forced=null;\n\t\tvar _isToBeIgnored=false;\n\n\t\t//////////\n\n\t\tlanguageSpecificOptions();\n\n\t\tlet p=[];\n\t\t//day\n\t\tp.push(_day ?? ((n!=null \u0026\u0026 n\u003E0n \u0026\u0026 n\u003C=31n) ? n : null));\n\t\t//month\n\t\tp.push(_month ?? ((n!=null \u0026\u0026 n\u003E0n \u0026\u0026 n\u003C=12n) ? n-1n :null));\n\t\t//year\n\t\tp.push(_year ?? n);\n\t\t//epoch\n\t\tp.push(_era);\n\n\t\tif (_forced!=null){\n\t\t\tfor (let j=0; j\u003C=3; ++j){\n\t\t\t\tif (_forced.find((v)=\u003E(v==j)) == undefined){\n\t\t\t\t\tp[j]=null;\t\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (forceToYear(elements[iAtt])){\n\t\t\tp[0]=null;\n\t\t\tp[1]=null;\n\t\t\tp[3]=null;\n\t\t}\n\n\t\tif (!_isToBeIgnored)\n\t\t\tpossibilities.push(p);\n\t}\n\t\n\n\tif (_constraintsList.length\u003E0){\n\t\tfor (let pAtt=0; pAtt\u003C possibilities.length; ++pAtt){\n\t\t\tfor (let c of _constraintsList){\n\t\t\t\tif ((c.type==AFTER \u0026\u0026 pAtt!=c.pos-1) ||\n\t\t\t\t    (c.type==BEFORE \u0026\u0026 pAtt!=c.pos) ||\n\t\t\t\t    (c.type==BEFORE_OR_AFTER \u0026\u0026 pAtt!=c.pos-1 \u0026\u0026 pAtt!=c.pos)){\n\t\t\t\t\tfor(let m of c.meaning){\n\t\t\t\t\t\tpossibilities[pAtt][m]=null;\t\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tpossibilities=possibilities.filter((v)=\u003E(v[0]!=null || v[1]!=null || v[2]!=null || v[3]!=null));\n\n\t//remove elements that are not present\n\tlet lettersToRemove=[];\n\tif(4\u003Epossibilities.length){\n\t\tfor (let i=0; i\u003C4; ++i){\n\t\t\tif (possibilities.find((p)=\u003Ep[i]!=null)==undefined){\n\t\t\t\tlettersToRemove.push(\"dmye\"[i]);\n\t\t\t}\n\t\t}\n\t}\n\t//remove elements according to the deletion chain\n\tfor(let i=0; 4-lettersToRemove.length\u003Epossibilities.length \u0026\u0026 i\u003Cdelete_chain.length; ++i){\n\t\tif (lettersToRemove.find((p)=\u003Ep==delete_chain[i])== undefined){\n\t\t\tlettersToRemove.push(delete_chain[i]);\n\t\t}\n\t}\n\t\n\tfor (let i=0; i\u003CprefOptions.length; ++i){\n\t\tlet actPref=prefOptions[i];\n\t\tlet d,m,y,e;\n\t\t\n\t\tfor (let l of lettersToRemove){\n\t\t\tactPref=actPref.replace(l,\"\");\n\t\t}\n\t\t\n\t\tfor (let j=0; j\u003CactPref.length; ++j){\n\t\t\tswitch(actPref[j]){\n\t\t\t\tcase \"d\":{\n\t\t\t\t\td=possibilities[j]?.[0]; break;\n\t\t\t\t}\n\t\t\t\tcase \"m\":{\n\t\t\t\t\tm=possibilities[j]?.[1]; break;\n\t\t\t\t}\n\t\t\t\tcase \"y\":{\n\t\t\t\t\ty=possibilities[j]?.[2]; break;\n\t\t\t\t}\n\t\t\t\tcase \"e\":{\n\t\t\t\t\te=possibilities[j]?.[3];break;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (y!=null \u0026\u0026 \n\t\t\t(lettersToRemove.find((p)=\u003Ep==\"e\")!= undefined || e!=null) \u0026\u0026\n\t\t\t(lettersToRemove.find((p)=\u003Ep==\"m\")!= undefined || m!=null) \u0026\u0026\n\t\t\t(lettersToRemove.find((p)=\u003Ep==\"d\")!= undefined || d!=null)\n\t\t\t){\n\t\t\tlet year;\n\t\t\tif (e!=null){\n\t\t\t\tyear = e==-1n ? -(y\u003C0n ? -y : y)+1n : (y\u003C0n ? -y : y);\n\t\t\t} else{\n\t\t\t\tyear=y;\n\t\t\t}\n\n\t\t\t// Wikifunctions.Debug({\n\t\t\t// \tK3: d,\n\t\t\t// \tK2: m,\n\t\t\t// \tK1: year\n\t\t\t// });\n\n\t\t\treturn year;\n\t\t}\n\t}\n\n}"
        }
    },
    "Z2K3": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11",
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1787",
                "Z11K2": "leggi anno gregoriano, dag, en (mga), js"
            }
        ]
    },
    "Z2K4": {
        "Z1K1": "Z32",
        "Z32K1": [
            "Z31"
        ]
    },
    "Z2K5": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11"
        ]
    }
}