Z23965

{
    "Z1K1": "Z2",
    "Z2K1": {
        "Z1K1": "Z6",
        "Z6K1": "Z23965"
    },
    "Z2K2": {
        "Z1K1": "Z14",
        "Z14K1": "Z23961",
        "Z14K3": {
            "Z1K1": "Z16",
            "Z16K1": "Z600",
            "Z16K2": "function Z23961( Z23961K1) {\n\tvar monthNames={\n\t\tgennaio:0n,\n\t\tfebbraio:1n,\n\t\tmarzo:2n,\n\t\taprile:3n,\n\t\tmaggio:4n,\n\t\tgiugno:5n,\n\t\tluglio:6n,\n\t\tagosto:7n,\n\t\tsettembre:8n,\n\t\tottobre:9n,\n\t\tnovembre:10n,\n\t\tdicembre:11n\n\t}; \n\tvar eraNames={\n\t\tac:-1n,\n\t\tdc:1n,\n\t\taec:-1n,\n\t\tec:1n,\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=[\"dmye\",\"yemd\",\"yedm\",\"mdye\"];\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\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\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\tZ23961K1=Z23961K1.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(Z23961K1)){\n\t\tZ23961K1=Z23961K1.split(\"T\")[0];\n\t\tvar list=Z23961K1.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\u003CZ23961K1.length;){\n\t\tlet s=separators.find((v)=\u003E Z23961K1.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]+=Z23961K1[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\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": "Z1002",
                "Z11K2": "lenient parse Gregorian Date, BigInt, it, js"
            },
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1787",
                "Z11K2": "leggi data gregoriana permissivo, BigInt, it, js"
            }
        ]
    },
    "Z2K4": {
        "Z1K1": "Z32",
        "Z32K1": [
            "Z31"
        ]
    },
    "Z2K5": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11",
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1002",
                "Z11K2": "is bugged"
            }
        ]
    }
}