Z24036

{
    "Z1K1": "Z2",
    "Z2K1": {
        "Z1K1": "Z6",
        "Z6K1": "Z24036"
    },
    "Z2K2": {
        "Z1K1": "Z14",
        "Z14K1": "Z23984",
        "Z14K3": {
            "Z1K1": "Z16",
            "Z16K1": "Z600",
            "Z16K2": "function Z23984( Z23984K1 ) {\n\tvar monthNames={\n\t\tJA:0,\n\t\tFE:1,\n\t\tMR:2,\n\t\tAP:3,\n\t\tMY:4,\n\t\tJN:5,\n\t\tJL:6,\n\t\tAU:7,\n\t\tSE:8,\n\t\tOC:9,\n\t\tNV:10,\n\t\tDE:11,\n\t\tjanuary:0,\n\t\tfebruary:1,\n\t\tmarch:2,\n\t\tapril:3,\n\t\tmay:4,\n\t\tjune:5,\n\t\tjuly:6,\n\t\taugust:7,\n\t\tseptember:8,\n\t\toctober:9,\n\t\tnovember:10,\n\t\tdecember:11\n\t};\n\tvar eraNames={\n\t\tad:+1,\n\t\tbc:-1,\n\t\tbce:-1,\n\t\tce:+1,\n\t};\n\tvar separators=[\" \",\"\\t\",\"/\",\"\\\\\",\"'\",'\"',\"|\"];\n\tvar prefOptions=[\"dmye\",\"dmey\",\"mdye\",\"mdey\",\"yemd\",\"eymd\",\"yedm\",\"eydm\"];\n\tvar ordinalStrings=[\"st\",\"nd\",\"rd\",\"th\"];\n\t\n\t\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\t\n\tfunction extractNumber(s){\n\t\tlet res=/-?[0-9]+/.exec(s);\n\t\tif (res!=null){\n\t\t\treturn Number(res);\n\t\t}\n\t\treturn null;\n\t}\n\t\n\tfunction extractMonthLiteral(s){\n\t\tfor (let m in monthNames){\n\t\t\tif (lenientComp(s,m)){\n\t\t\t\treturn monthNames[m];\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\tfunction extractEpoch(s){\n\t\tfor (let m in eraNames){\n\t\t\tif (lenientComp(s,m)){\n\t\t\t\treturn eraNames[m];\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\tfunction extractOrdinal(s){\n\t\tfor (let m of ordinalStrings){\n\t\t\tif (lenientComp(s,m)){\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\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\t\n\tZ23984K1=Z23984K1.replaceAll(/-|—|‒|–|—|⸺|⸺/g,\"-\");\n\t\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(Z23984K1)){\n\t\tZ23984K1=Z23984K1.split(\"T\")[0];\n\t\tvar list=Z23984K1.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\t\n\tvar elements=[\"\"];\n\tfor (let i=0; i\u003CZ23984K1.length;){\n\t\tlet s=separators.find((v)=\u003E Z23984K1.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]+=Z23984K1[i++];\n\t}\n\tif(elements[elements.length-1]==\"\") elements.pop();\n\t\n\tif(elements.length\u003C3){\n\t\tlet elSeparato=[];\n\t\tfor (let i=0; i\u003Celements.length; ++i){\n\t\t\telSeparato=elements[i].split(\"-\");\n\t\t}\n\t\telements=elSeparato.flat();\n\t}\n\t// Wikifunctions.Debug(elements);\n\t\n\tlet elSeparato=[];\n\tfor (let i=0; i\u003Celements.length; ++i){\n\t\telSeparato.push(/-?\\+?[0-9]+/.exec(elements[i]));\n\t\telSeparato.push(elements[i].split(/-?\\+?[0-9]+/));\n\t}\n\telSeparato=elSeparato.flat();\n\telements=elSeparato.filter((v)=\u003E(v!=null \u0026\u0026 v!=\"\"));\n\t\n\t //Wikifunctions.Debug(\"elements:\");\n\t //Wikifunctions.Debug(elements);\n\t\n\t//Order of possibilities: dmye\n\tvar possibilities=[];\n\tfor(let i=0; i\u003Celements.length; ++i){\n\t\tlet p=[];\n\t\tlet n=extractNumber(elements[i]);\n\t\tlet m=extractMonthLiteral(elements[i]);\n\t\tlet e=extractEpoch(elements[i]);\n\t\t\n\t\t//day\n\t\tp.push((n!=null \u0026\u0026 n\u003E0 \u0026\u0026 n\u003C=31) ? n : null);\n\t\t//month\n\t\tp.push((n!=null \u0026\u0026 n\u003E0 \u0026\u0026 n\u003C=12) ? n-1 : (m!=null ? m : null));\n\t\t//year\n\t\tp.push(n!=null ? n : null);\n\t\t//epoch\n\t\tp.push(e);\n\t\t\n\t\tif (forceToYear(elements[i])){\n\t\t\tp[0]=null;\n\t\t\tp[1]=null;\n\t\t\tp[3]=null;\n\t\t}\n\t\t\n\t\tpossibilities.push(p);\n\t\t\n\t\t//Force ordinals to be dates\n\t\tif(extractOrdinal(elements[i])){\n\t\t\t// Wikifunctions.Debug(possibilities);\n\t\t\tpossibilities[possibilities.length-2][1]=null;\n\t\t\tpossibilities[possibilities.length-2][2]=null;\n\t\t\tpossibilities[possibilities.length-2][3]=null;\n\t\t}\n\t}\n\t\n\tpossibilities=possibilities.filter((v)=\u003E(v[0]!=null || v[1]!=null || v[2]!=null || v[3]!=null));\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\tif (possibilities.length\u003C4) actPref=actPref.replace(\"e\",\"\");\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\t\t\n\t\tif (d!=null \u0026\u0026 m!=null \u0026\u0026 y!=null){\n\t\t\tlet year;\n\t\t\tif (e!=null){\n\t\t\t\tyear = e==-1 ? -Math.abs(y)+1 : Math.abs(y);\n\t\t\t} else{\n\t\t\t\tyear=y;\n\t\t\t}\n\t\t\t\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\t\t\t\n\t\t\treturn{\n\t\t\t\tK3: (d),\n\t\t\t\tK2: (m),\n\t\t\t\tK1: BigInt(year)\n\t\t\t};\n\t\t}\n\t}\n}"
        }
    },
    "Z2K3": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11",
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1787",
                "Z11K2": "leggi data gregoriana perm, constr, en (gma), js"
            },
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1002",
                "Z11K2": "lenient parse Gregorian Date, constr, en, dmy, js"
            }
        ]
    },
    "Z2K4": {
        "Z1K1": "Z32",
        "Z32K1": [
            "Z31"
        ]
    },
    "Z2K5": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11"
        ]
    }
}