Z23980

{
    "Z1K1": "Z2",
    "Z2K1": {
        "Z1K1": "Z6",
        "Z6K1": "Z23980"
    },
    "Z2K2": {
        "Z1K1": "Z14",
        "Z14K1": "Z23976",
        "Z14K3": {
            "Z1K1": "Z16",
            "Z16K1": "Z600",
            "Z16K2": "function Z23976( Z23976K1 ) {\n\tvar monthNames={\n\t};\n\tvar eraNames={\n\t\tad:1n,\n\t\tbc:-1n,\n\t\tbce:-1n,\n\t\tce:1n,\n\t};\n\tvar separators=[\" \",\"\\t\",\"/\",\"\\\\\",\"'\",'\"',\"|\"];\n\tvar prefOptions=[\"yemd\",\"eymd\",\"dmye\",\"dmey\",\"mdye\",\"mdey\",\"yedm\",\"eydm\",];\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 BigInt(res[0]);\n\t\t}\n\t\treturn null;\n\t}\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\tif (res.length\u003E2) return true;\n\t\tif (res[0]==\"-\" || res[0]==\"+\") return true;\n\t\treturn false;\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\t\n\tZ23976K1=Z23976K1.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(Z23976K1)){\n\t\tZ23976K1=Z23976K1.split(\"T\")[0];\n\t\tvar list=Z23976K1.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\u003CZ23976K1.length;){\n\t\tlet s=separators.find((v)=\u003E Z23976K1.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]+=Z23976K1[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.push(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\u003E0n \u0026\u0026 n\u003C=31n) ? n : null);\n\t\t//month\n\t\tp.push((n!=null \u0026\u0026 n\u003E0n \u0026\u0026 n\u003C=12n) ? n-1n : (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\tpossibilities.push(p);\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==-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\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: Number(d),\n\t\t\t\tK2: Number(m),\n\t\t\t\tK1: (year)\n\t\t\t};\n\t\t}\n\t}\n}"
        }
    },
    "Z2K3": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11",
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1787",
                "Z11K2": "leggi data gregoriana permissivo, BigInt, mul, js"
            },
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1002",
                "Z11K2": "lenient read Gregorian Date, BigInt, mul, js"
            }
        ]
    },
    "Z2K4": {
        "Z1K1": "Z32",
        "Z32K1": [
            "Z31"
        ]
    },
    "Z2K5": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11"
        ]
    }
}