Z28686

{
    "Z1K1": "Z2",
    "Z2K1": {
        "Z1K1": "Z6",
        "Z6K1": "Z28686"
    },
    "Z2K2": {
        "Z1K1": "Z46",
        "Z46K1": "Z28686",
        "Z46K2": "Z6064",
        "Z46K3": {
            "Z1K1": "Z16",
            "Z16K1": "Z600",
            "Z16K2": "function Z28686( Z28686K1 ) {\n\t// Assumes that Z28686K1.Z6064K1.Z6061K1 is a Gregorian date (Z20420);\n\t// that's ensured by Wikifunctions fetch code (for now)\n\n\tfunction isVoid( value ) {\n\t\treturn ( typeof value === 'object' \u0026\u0026\n\t\t\t( ( value.Z1K1 === 'Z9' \u0026\u0026 value.Z9K1 === 'Z24' ) ||\n\t\t\t\t( value.Z1K1 === 'Z21' ) ||\n\t\t\t\t( typeof value.Z1K1 === 'object' \u0026\u0026\n\t\t\t\t\tvalue.Z1K1.Z1K1 === 'Z9' \u0026\u0026 value.Z1K1.Z9K1 === 'Z21' ) )\n\t\t);\n\t}\n\n\t// Construct JavaScript object for an instance of Z20420\n\t// Copied from Z20438 (changing the function and argument names,\n\t// and checking for isVoid(month))\n\tfunction fromGregorianCalendarDate( Z20420 ) {\n\t\tlet era = Z20420.Z20420K1.Z20159K1;\n\t\tif (typeof era === 'object') {\n\t\t\tif ( 'Z17813K1' in era ) {\n\t\t\t\tera = era.Z17813K1;\n\t\t\t}\n\t\t}\n\t\tif (typeof era === 'object') {\n\t\t\tif ( 'Z9K1' in era ) {\n\t\t\t\tera = era.Z9K1;\n\t\t\t}\n\t\t}\n\n\t\tlet year = Z20420.Z20420K1.Z20159K2.Z13518K1;\n\t\tif (typeof year !== 'string') {\n\t\t\tif ( 'Z6K1' in year ) {\n\t\t\t\tyear = year.Z6K1;\n\t\t\t}\n\t\t}\n\n\t\tlet month = Z20420.Z20420K2.Z20342K1;\n\t\tif ( isVoid( month ) ) {\n\t\t\tmonth = null;\n\t\t} else {\n\t\t\tif (typeof month === 'object') {\n\t\t\t\tif ('Z16098K1' in month) {\n\t\t\t\t\tmonth = month.Z16098K1;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (typeof month === 'object') {\n\t\t\t\tif ('Z9K1' in month) {\n\t\t\t\t\tmonth = month.Z9K1;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// (I think?) month can safely be a number, because it should only be from 0-11\n\t\t\tmonth = parseInt(month.split(\"Z\")[1]);\n\t\t\tmonth = month - 16101;\n\t\t\t// If for some reason something that's not a month gets in here, throw.\n\t\t\tif (month \u003C 0 || month \u003E 11) {\n\t\t\t\tthrow new Error(\"Received non-month ZObject\");\n\t\t\t}\n\t\t}\n\n\t\tlet day = Z20420.Z20420K2.Z20342K2.Z13518K1;\n\t\tif (typeof day !== 'string') {\n\t\t\tif ( 'Z6K1' in day ) {\n\t\t\t\tday = day.Z6K1;\n\t\t\t}\n\t\t}\n\t\tday = parseInt( day );\n\n\t\tyear = BigInt( year );\n\t\tif ( era === \"Z17815\" ) {\n\t\t\tyear = year * -1n + 1n;\n\t\t}\n\n\t\treturn {\n\t\t\t'K1': year,\n\t\t\t'K2': month,\n\t\t\t'K3': day\n\t\t};\n\t}\n\n\t// Construct JavaScript object for an instance of Z6060\n\t// Copied from Z25176 (changing just the function and argument names)\n\tfunction fromTimeOfDay( Z6060 ) {\n\t\tlet hour = Z6060.Z6060K1.Z13518K1;\n\t\tif (typeof hour !== 'string') {\n\t\t\tif ( 'Z6K1' in hour ) {\n\t\t\t\thour = hour.Z6K1;\n\t\t\t}\n\t\t}\n\t\thour = parseInt( hour );\n\t\tif (hour \u003C 0 || hour \u003E 23) {\n\t\t\tthrow new Error(\"Received Zobject representing Time of day with invalid hour\");\n\t\t}\n\n\t\tlet minute = Z6060.Z6060K2.Z13518K1;\n\t\tif (typeof minute !== 'string') {\n\t\t\tif ( 'Z6K1' in minute ) {\n\t\t\t\tminute = minute.Z6K1;\n\t\t\t}\n\t\t}\n\t\tminute = parseInt( minute );\n\t\tif (minute \u003C 0 || minute \u003E 59) {\n\t\t\tthrow new Error(\"Received Zobject representing Time of day with invalid minute\");\n\t\t}\n\n\t\tlet second = Z6060.Z6060K3.Z13518K1;\n\t\tif (typeof second !== 'string') {\n\t\t\tif ( 'Z6K1' in second ) {\n\t\t\t\tsecond = second.Z6K1;\n\t\t\t}\n\t\t}\n\t\tsecond = parseInt( second );\n\t\tif (second \u003C 0 || second \u003E 60) {\n\t\t\tthrow new Error(\"Received Zobject representing Time of day with invalid second\");\n\t\t}\n\n\t\treturn {\n\t\t\t'K1': hour,\n\t\t\t'K2': minute,\n\t\t\t'K3': second\n\t\t};\n\t}\n\n\t// Construct JavaScript object for an instance of Z13518\n\t// Copied from Z13519 (changing just the function and argument names)\n\tfunction fromNaturalNumber( Z13518 ) {\n\t\tconst x = Z13518.Z13518K1;\n\t\tif (typeof x === 'string') {\n\t\t\treturn BigInt( Z13518.Z13518K1 );\n\t\t} else {\n\t\t\treturn BigInt( Z13518.Z13518K1.Z6K1 );\n\t\t}\n\t}\n\n\t// Construct JavaScript object for an instance of Z16683\n\t// Copied from Z16684 (changing just the function and argument names)\n\tfunction fromInteger( Z16683 ) {\n\t\tlet value = Z16683.Z16683K2.Z13518K1;\n\t\tif (typeof value === 'string') {\n\t\t\tvalue = BigInt( Z16683.Z16683K2.Z13518K1 );\n\t\t} else {\n\t\t\tvalue = BigInt( Z16683.Z16683K2.Z13518K1.Z6K1 );\n\t\t}\n\t\tlet sign = Z16683.Z16683K1.Z16659K1;\n\n\t\twhile ( typeof sign === 'object' ) {\n\t\t\tif ( 'Z9K1' in sign ) {\n\t\t\t\tsign = sign.Z9K1;\n\t\t\t} else if ( 'Z16659K1' in sign ) {\n\t\t\t\tsign = sign.Z16659K1;\n\t\t\t} else {\n\t\t\t\tsign = '';\n\t\t\t}\n\t\t}\n\n\t\t// Now sign is a string, with a value or empty\n\t\t// (it could be also undefined or null, which\n\t\t// means default value will be assigned)\n\t\tif ( sign === 'Z16662' ) {\n\t\t\tsign = -1n;\n\t\t} else if ( sign === 'Z16661' ) {\n\t\t\tsign = 0n;\n\t\t} else {\n\t\t\tsign = 1n;\n\t\t}\n\n\t\tif ( value \u003E 0n \u0026\u0026 sign === 0n ) {\n\t\t\treturn value;\n\t\t}\n\n\t\treturn sign * value;\n\t}\n\n\tconst date = fromGregorianCalendarDate( Z28686K1.Z6064K1.Z6061K1 );\n\tconst timeOfDay = fromTimeOfDay( Z28686K1.Z6064K1.Z6061K2 );\n\tconst datetime = { K1: date, K2: timeOfDay }\n\n\t// Extract the QID from the enum instance\n\tconst precision = Z28686K1.Z6064K2.Z6062K1.Z6091K1.Z6K1;\n\tconst before = fromNaturalNumber( Z28686K1.Z6064K3 );\n\tconst after = fromNaturalNumber( Z28686K1.Z6064K4 );\n\tconst timeZone = fromInteger( Z28686K1.Z6064K5 );\n\t// Extract the QID from the enum instance\n\tconst calendarModel = Z28686K1.Z6064K6.Z6063K1.Z6091K1.Z6K1;\n\n\treturn {\n\t\tK1: datetime,\n\t\tK2: precision,\n\t\tK3: before,\n\t\tK4: after,\n\t\tK5: timeZone,\n\t\tK6: calendarModel\n\t}\n}"
        },
        "Z46K4": "Object"
    },
    "Z2K3": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11",
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1002",
                "Z11K2": "Convert from Wikidata time, JavaScript"
            }
        ]
    },
    "Z2K4": {
        "Z1K1": "Z32",
        "Z32K1": [
            "Z31"
        ]
    },
    "Z2K5": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11"
        ]
    }
}