UNPKG

luxon

Version:
1,540 lines (1,539 loc) 2.7 MB
{ "type": "File", "start": 0, "end": 12020, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 374, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 12020, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 374, "column": 0 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 30, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 30 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 9, "end": 13, "loc": { "start": { "line": 1, "column": 9 }, "end": { "line": 1, "column": 13 } }, "imported": { "type": "Identifier", "start": 9, "end": 13, "loc": { "start": { "line": 1, "column": 9 }, "end": { "line": 1, "column": 13 }, "identifierName": "Util" }, "name": "Util" }, "local": { "type": "Identifier", "start": 9, "end": 13, "loc": { "start": { "line": 1, "column": 9 }, "end": { "line": 1, "column": 13 }, "identifierName": "Util" }, "name": "Util" } } ], "source": { "type": "StringLiteral", "start": 21, "end": 29, "loc": { "start": { "line": 1, "column": 21 }, "end": { "line": 1, "column": 29 } }, "extra": { "rawValue": "./util", "raw": "'./util'" }, "value": "./util" } }, { "type": "ImportDeclaration", "start": 31, "end": 70, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 39 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 40, "end": 48, "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 17 } }, "imported": { "type": "Identifier", "start": 40, "end": 48, "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 17 }, "identifierName": "DateTime" }, "name": "DateTime" }, "local": { "type": "Identifier", "start": 40, "end": 48, "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 17 }, "identifierName": "DateTime" }, "name": "DateTime" } } ], "source": { "type": "StringLiteral", "start": 56, "end": 69, "loc": { "start": { "line": 2, "column": 25 }, "end": { "line": 2, "column": 38 } }, "extra": { "rawValue": "../datetime", "raw": "'../datetime'" }, "value": "../datetime" } }, { "type": "ImportDeclaration", "start": 71, "end": 107, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 36 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 80, "end": 87, "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 16 } }, "imported": { "type": "Identifier", "start": 80, "end": 87, "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 16 }, "identifierName": "English" }, "name": "English" }, "local": { "type": "Identifier", "start": 80, "end": 87, "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 16 }, "identifierName": "English" }, "name": "English" } } ], "source": { "type": "StringLiteral", "start": 95, "end": 106, "loc": { "start": { "line": 3, "column": 24 }, "end": { "line": 3, "column": 35 } }, "extra": { "rawValue": "./english", "raw": "'./english'" }, "value": "./english" } }, { "type": "FunctionDeclaration", "start": 109, "end": 325, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 15, "column": 1 } }, "id": { "type": "Identifier", "start": 118, "end": 133, "loc": { "start": { "line": 5, "column": 9 }, "end": { "line": 5, "column": 24 }, "identifierName": "stringifyTokens" }, "name": "stringifyTokens" }, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 134, "end": 140, "loc": { "start": { "line": 5, "column": 25 }, "end": { "line": 5, "column": 31 }, "identifierName": "splits" }, "name": "splits" }, { "type": "Identifier", "start": 142, "end": 155, "loc": { "start": { "line": 5, "column": 33 }, "end": { "line": 5, "column": 46 }, "identifierName": "tokenToString" }, "name": "tokenToString" } ], "body": { "type": "BlockStatement", "start": 157, "end": 325, "loc": { "start": { "line": 5, "column": 48 }, "end": { "line": 15, "column": 1 } }, "body": [ { "type": "VariableDeclaration", "start": 161, "end": 172, "loc": { "start": { "line": 6, "column": 2 }, "end": { "line": 6, "column": 13 } }, "declarations": [ { "type": "VariableDeclarator", "start": 165, "end": 171, "loc": { "start": { "line": 6, "column": 6 }, "end": { "line": 6, "column": 12 } }, "id": { "type": "Identifier", "start": 165, "end": 166, "loc": { "start": { "line": 6, "column": 6 }, "end": { "line": 6, "column": 7 }, "identifierName": "s" }, "name": "s" }, "init": { "type": "StringLiteral", "start": 169, "end": 171, "loc": { "start": { "line": 6, "column": 10 }, "end": { "line": 6, "column": 12 } }, "extra": { "rawValue": "", "raw": "''" }, "value": "" } } ], "kind": "let" }, { "type": "ForOfStatement", "start": 175, "end": 311, "loc": { "start": { "line": 7, "column": 2 }, "end": { "line": 13, "column": 3 } }, "left": { "type": "VariableDeclaration", "start": 180, "end": 191, "loc": { "start": { "line": 7, "column": 7 }, "end": { "line": 7, "column": 18 } }, "declarations": [ { "type": "VariableDeclarator", "start": 186, "end": 191, "loc": { "start": { "line": 7, "column": 13 }, "end": { "line": 7, "column": 18 } }, "id": { "type": "Identifier", "start": 186, "end": 191, "loc": { "start": { "line": 7, "column": 13 }, "end": { "line": 7, "column": 18 }, "identifierName": "token" }, "name": "token" }, "init": null } ], "kind": "const" }, "right": { "type": "Identifier", "start": 195, "end": 201, "loc": { "start": { "line": 7, "column": 22 }, "end": { "line": 7, "column": 28 }, "identifierName": "splits" }, "name": "splits" }, "body": { "type": "BlockStatement", "start": 203, "end": 311, "loc": { "start": { "line": 7, "column": 30 }, "end": { "line": 13, "column": 3 } }, "body": [ { "type": "IfStatement", "start": 209, "end": 307, "loc": { "start": { "line": 8, "column": 4 }, "end": { "line": 12, "column": 5 } }, "test": { "type": "MemberExpression", "start": 213, "end": 226, "loc": { "start": { "line": 8, "column": 8 }, "end": { "line": 8, "column": 21 } }, "object": { "type": "Identifier", "start": 213, "end": 218, "loc": { "start": { "line": 8, "column": 8 }, "end": { "line": 8, "column": 13 }, "identifierName": "token" }, "name": "token" }, "property": { "type": "Identifier", "start": 219, "end": 226, "loc": { "start": { "line": 8, "column": 14 }, "end": { "line": 8, "column": 21 }, "identifierName": "literal" }, "name": "literal" }, "computed": false }, "consequent": { "type": "BlockStatement", "start": 228, "end": 257, "loc": { "start": { "line": 8, "column": 23 }, "end": { "line": 10, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 236, "end": 251, "loc": { "start": { "line": 9, "column": 6 }, "end": { "line": 9, "column": 21 } }, "expression": { "type": "AssignmentExpression", "start": 236, "end": 250, "loc": { "start": { "line": 9, "column": 6 }, "end": { "line": 9, "column": 20 } }, "operator": "+=", "left": { "type": "Identifier", "start": 236, "end": 237, "loc": { "start": { "line": 9, "column": 6 }, "end": { "line": 9, "column": 7 }, "identifierName": "s" }, "name": "s" }, "right": { "type": "MemberExpression", "start": 241, "end": 250, "loc": { "start": { "line": 9, "column": 11 }, "end": { "line": 9, "column": 20 } }, "object": { "type": "Identifier", "start": 241, "end": 246, "loc": { "start": { "line": 9, "column": 11 }, "end": { "line": 9, "column": 16 }, "identifierName": "token" }, "name": "token" }, "property": { "type": "Identifier", "start": 247, "end": 250, "loc": { "start": { "line": 9, "column": 17 }, "end": { "line": 9, "column": 20 }, "identifierName": "val" }, "name": "val" }, "computed": false } } } ], "directives": [] }, "alternate": { "type": "BlockStatement", "start": 263, "end": 307, "loc": { "start": { "line": 10, "column": 11 }, "end": { "line": 12, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 271, "end": 301, "loc": { "start": { "line": 11, "column": 6 }, "end": { "line": 11, "column": 36 } }, "expression": { "type": "AssignmentExpression", "start": 271, "end": 300, "loc": { "start": { "line": 11, "column": 6 }, "end": { "line": 11, "column": 35 } }, "operator": "+=", "left": { "type": "Identifier", "start": 271, "end": 272, "loc": { "start": { "line": 11, "column": 6 }, "end": { "line": 11, "column": 7 }, "identifierName": "s" }, "name": "s" }, "right": { "type": "CallExpression", "start": 276, "end": 300, "loc": { "start": { "line": 11, "column": 11 }, "end": { "line": 11, "column": 35 } }, "callee": { "type": "Identifier", "start": 276, "end": 289, "loc": { "start": { "line": 11, "column": 11 }, "end": { "line": 11, "column": 24 }, "identifierName": "tokenToString" }, "name": "tokenToString" }, "arguments": [ { "type": "MemberExpression", "start": 290, "end": 299, "loc": { "start": { "line": 11, "column": 25 }, "end": { "line": 11, "column": 34 } }, "object": { "type": "Identifier", "start": 290, "end": 295, "loc": { "start": { "line": 11, "column": 25 }, "end": { "line": 11, "column": 30 }, "identifierName": "token" }, "name": "token" }, "property": { "type": "Identifier", "start": 296, "end": 299, "loc": { "start": { "line": 11, "column": 31 }, "end": { "line": 11, "column": 34 }, "identifierName": "val" }, "name": "val" }, "computed": false } ] } } } ], "directives": [] } } ], "directives": [] } }, { "type": "ReturnStatement", "start": 314, "end": 323, "loc": { "start": { "line": 14, "column": 2 }, "end": { "line": 14, "column": 11 } }, "argument": { "type": "Identifier", "start": 321, "end": 322, "loc": { "start": { "line": 14, "column": 9 }, "end": { "line": 14, "column": 10 }, "identifierName": "s" }, "name": "s" } } ], "directives": [], "trailingComments": null }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * @private\n ", "start": 327, "end": 346, "loc": { "start": { "line": 17, "column": 0 }, "end": { "line": 19, "column": 3 } } } ] }, { "type": "ExportNamedDeclaration", "start": 348, "end": 12019, "loc": { "start": { "line": 21, "column": 0 }, "end": { "line": 373, "column": 1 } }, "specifiers": [], "source": null, "declaration": { "type": "ClassDeclaration", "start": 355, "end": 12019, "loc": { "start": { "line": 21, "column": 7 }, "end": { "line": 373, "column": 1 } }, "id": { "type": "Identifier", "start": 361, "end": 370, "loc": { "start": { "line": 21, "column": 13 }, "end": { "line": 21, "column": 22 }, "identifierName": "Formatter" }, "name": "Formatter", "leadingComments": null }, "superClass": null, "body": { "type": "ClassBody", "start": 371, "end": 12019, "loc": { "start": { "line": 21, "column": 23 }, "end": { "line": 373, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 375, "end": 524, "loc": { "start": { "line": 22, "column": 2 }, "end": { "line": 25, "column": 3 } }, "computed": false, "key": { "type": "Identifier", "start": 382, "end": 388, "loc": { "start": { "line": 22, "column": 9 }, "end": { "line": 22, "column": 15 }, "identifierName": "create" }, "name": "create" }, "static": true, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 389, "end": 395, "loc": { "start": { "line": 22, "column": 16 }, "end": { "line": 22, "column": 22 }, "identifierName": "locale" }, "name": "locale" }, { "type": "AssignmentPattern", "start": 397, "end": 406, "loc": { "start": { "line": 22, "column": 24 }, "end": { "line": 22, "column": 33 } }, "left": { "type": "Identifier", "start": 397, "end": 401, "loc": { "start": { "line": 22, "column": 24 }, "end": { "line": 22, "column": 28 }, "identifierName": "opts" }, "name": "opts" }, "right": { "type": "ObjectExpression", "start": 404, "end": 406, "loc": { "start": { "line": 22, "column": 31 }, "end": { "line": 22, "column": 33 } }, "properties": [] } } ], "body": { "type": "BlockStatement", "start": 408, "end": 524, "loc": { "start": { "line": 22, "column": 35 }, "end": { "line": 25, "column": 3 } }, "body": [ { "type": "VariableDeclaration", "start": 414, "end": 474, "loc": { "start": { "line": 23, "column": 4 }, "end": { "line": 23, "column": 64 } }, "declarations": [ { "type": "VariableDeclarator", "start": 420, "end": 473, "loc": { "start": { "line": 23, "column": 10 }, "end": { "line": 23, "column": 63 } }, "id": { "type": "Identifier", "start": 420, "end": 430, "loc": { "start": { "line": 23, "column": 10 }, "end": { "line": 23, "column": 20 }, "identifierName": "formatOpts" }, "name": "formatOpts" }, "init": { "type": "CallExpression", "start": 433, "end": 473, "loc": { "start": { "line": 23, "column": 23 }, "end": { "line": 23, "column": 63 } }, "callee": { "type": "MemberExpression", "start": 433, "end": 446, "loc": { "start": { "line": 23, "column": 23 }, "end": { "line": 23, "column": 36 } }, "object": { "type": "Identifier", "start": 433, "end": 439, "loc": { "start": { "line": 23, "column": 23 }, "end": { "line": 23, "column": 29 }, "identifierName": "Object" }, "name": "Object" }, "property": { "type": "Identifier", "start": 440, "end": 446, "loc": { "start": { "line": 23, "column": 30 }, "end": { "line": 23, "column": 36 }, "identifierName": "assign" }, "name": "assign" }, "computed": false }, "arguments": [ { "type": "ObjectExpression", "start": 447, "end": 449, "loc": { "start": { "line": 23, "column": 37 }, "end": { "line": 23, "column": 39 } }, "properties": [] }, { "type": "ObjectExpression", "start": 451, "end": 466, "loc": { "start": { "line": 23, "column": 41 }, "end": { "line": 23, "column": 56 } }, "properties": [ { "type": "ObjectProperty", "start": 453, "end": 464, "loc": { "start": { "line": 23, "column": 43 }, "end": { "line": 23, "column": 54 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 453, "end": 458, "loc": { "start": { "line": 23, "column": 43 }, "end": { "line": 23, "column": 48 }, "identifierName": "round" }, "name": "round" }, "value": { "type": "BooleanLiteral", "start": 460, "end": 464, "loc": { "start": { "line": 23, "column": 50 }, "end": { "line": 23, "column": 54 } }, "value": true } } ] }, { "type": "Identifier", "start": 468, "end": 472, "loc": { "start": { "line": 23, "column": 58 }, "end": { "line": 23, "column": 62 }, "identifierName": "opts" }, "name": "opts" } ] } } ], "kind": "const" }, { "type": "ReturnStatement", "start": 479, "end": 520, "loc": { "start": { "line": 24, "column": 4 }, "end": { "line": 24, "column": 45 } }, "argument": { "type": "NewExpression", "start": 486, "end": 519, "loc": { "start": { "line": 24, "column": 11 }, "end": { "line": 24, "column": 44 } }, "callee": { "type": "Identifier", "start": 490, "end": 499, "loc": { "start": { "line": 24, "column": 15 }, "end": { "line": 24, "column": 24 }, "identifierName": "Formatter" }, "name": "Formatter" }, "arguments": [ { "type": "Identifier", "start": 500, "end": 506, "loc": { "start": { "line": 24, "column": 25 }, "end": { "line": 24, "column": 31 }, "identifierName": "locale" }, "name": "locale" }, { "type": "Identifier", "start": 508, "end": 518, "loc": { "start": { "line": 24, "column": 33 }, "end": { "line": 24, "column": 43 }, "identifierName": "formatOpts" }, "name": "formatOpts" } ] } } ], "directives": [] } }, { "type": "ClassMethod", "start": 528, "end": 1367, "loc": { "start": { "line": 27, "column": 2 }, "end": { "line": 59, "column": 3 } }, "computed": false, "key": { "type": "Identifier", "start": 535, "end": 546, "loc": { "start": { "line": 27, "column": 9 }, "end": { "line": 27, "column": 20 }, "identifierName": "parseFormat" }, "name": "parseFormat" }, "static": true, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 547, "end": 550, "loc": { "start": { "line": 27, "column": 21 }, "end": { "line": 27, "column": 24 }, "identifierName": "fmt" }, "name": "fmt" } ], "body": { "type": "BlockStatement", "start": 552, "end": 1367, "loc": { "start": { "line": 27, "column": 26 }, "end": { "line": 59, "column": 3 } }, "body": [ { "type": "VariableDeclaration", "start": 558, "end": 626, "loc": { "start": { "line": 28, "column": 4 }, "end": { "line": 30, "column": 24 } }, "declarations": [ { "type": "VariableDeclarator", "start": 562, "end": 576, "loc": { "start": { "line": 28, "column": 8 }, "end": { "line": 28, "column": 22 } }, "id": { "type": "Identifier", "start": 562, "end": 569, "loc": { "start": { "line": 28, "column": 8 }, "end": { "line": 28, "column": 15 }, "identifierName": "current" }, "name": "current" }, "init": { "type": "NullLiteral",