luxon
Version:
Immutable date wrapper
1,583 lines (1,582 loc) • 1.22 MB
JSON
{
"type": "File",
"start": 0,
"end": 5762,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 206,
"column": 0
}
},
"program": {
"type": "Program",
"start": 0,
"end": 5762,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 206,
"column": 0
}
},
"sourceType": "module",
"body": [
{
"type": "ImportDeclaration",
"start": 0,
"end": 39,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 39
}
},
"specifiers": [
{
"type": "ImportSpecifier",
"start": 9,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 17
}
},
"imported": {
"type": "Identifier",
"start": 9,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 17
},
"identifierName": "Duration"
},
"name": "Duration"
},
"local": {
"type": "Identifier",
"start": 9,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 17
},
"identifierName": "Duration"
},
"name": "Duration"
}
}
],
"source": {
"type": "StringLiteral",
"start": 25,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 25
},
"end": {
"line": 1,
"column": 38
}
},
"extra": {
"rawValue": "../duration",
"raw": "'../duration'"
},
"value": "../duration"
}
},
{
"type": "ImportDeclaration",
"start": 40,
"end": 79,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 39
}
},
"specifiers": [
{
"type": "ImportSpecifier",
"start": 49,
"end": 57,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 17
}
},
"imported": {
"type": "Identifier",
"start": 49,
"end": 57,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 17
},
"identifierName": "DateTime"
},
"name": "DateTime"
},
"local": {
"type": "Identifier",
"start": 49,
"end": 57,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 17
},
"identifierName": "DateTime"
},
"name": "DateTime"
}
}
],
"source": {
"type": "StringLiteral",
"start": 65,
"end": 78,
"loc": {
"start": {
"line": 2,
"column": 25
},
"end": {
"line": 2,
"column": 38
}
},
"extra": {
"rawValue": "../datetime",
"raw": "'../datetime'"
},
"value": "../datetime"
}
},
{
"type": "ImportDeclaration",
"start": 80,
"end": 111,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 3,
"column": 31
}
},
"specifiers": [
{
"type": "ImportSpecifier",
"start": 89,
"end": 93,
"loc": {
"start": {
"line": 3,
"column": 9
},
"end": {
"line": 3,
"column": 13
}
},
"imported": {
"type": "Identifier",
"start": 89,
"end": 93,
"loc": {
"start": {
"line": 3,
"column": 9
},
"end": {
"line": 3,
"column": 13
},
"identifierName": "Zone"
},
"name": "Zone"
},
"local": {
"type": "Identifier",
"start": 89,
"end": 93,
"loc": {
"start": {
"line": 3,
"column": 9
},
"end": {
"line": 3,
"column": 13
},
"identifierName": "Zone"
},
"name": "Zone"
}
}
],
"source": {
"type": "StringLiteral",
"start": 101,
"end": 110,
"loc": {
"start": {
"line": 3,
"column": 21
},
"end": {
"line": 3,
"column": 30
}
},
"extra": {
"rawValue": "../zone",
"raw": "'../zone'"
},
"value": "../zone"
}
},
{
"type": "ImportDeclaration",
"start": 112,
"end": 159,
"loc": {
"start": {
"line": 4,
"column": 0
},
"end": {
"line": 4,
"column": 47
}
},
"specifiers": [
{
"type": "ImportSpecifier",
"start": 121,
"end": 130,
"loc": {
"start": {
"line": 4,
"column": 9
},
"end": {
"line": 4,
"column": 18
}
},
"imported": {
"type": "Identifier",
"start": 121,
"end": 130,
"loc": {
"start": {
"line": 4,
"column": 9
},
"end": {
"line": 4,
"column": 18
},
"identifierName": "LocalZone"
},
"name": "LocalZone"
},
"local": {
"type": "Identifier",
"start": 121,
"end": 130,
"loc": {
"start": {
"line": 4,
"column": 9
},
"end": {
"line": 4,
"column": 18
},
"identifierName": "LocalZone"
},
"name": "LocalZone"
}
}
],
"source": {
"type": "StringLiteral",
"start": 138,
"end": 158,
"loc": {
"start": {
"line": 4,
"column": 26
},
"end": {
"line": 4,
"column": 46
}
},
"extra": {
"rawValue": "../zones/localZone",
"raw": "'../zones/localZone'"
},
"value": "../zones/localZone"
}
},
{
"type": "ImportDeclaration",
"start": 160,
"end": 205,
"loc": {
"start": {
"line": 5,
"column": 0
},
"end": {
"line": 5,
"column": 45
}
},
"specifiers": [
{
"type": "ImportSpecifier",
"start": 169,
"end": 177,
"loc": {
"start": {
"line": 5,
"column": 9
},
"end": {
"line": 5,
"column": 17
}
},
"imported": {
"type": "Identifier",
"start": 169,
"end": 177,
"loc": {
"start": {
"line": 5,
"column": 9
},
"end": {
"line": 5,
"column": 17
},
"identifierName": "IANAZone"
},
"name": "IANAZone"
},
"local": {
"type": "Identifier",
"start": 169,
"end": 177,
"loc": {
"start": {
"line": 5,
"column": 9
},
"end": {
"line": 5,
"column": 17
},
"identifierName": "IANAZone"
},
"name": "IANAZone"
}
}
],
"source": {
"type": "StringLiteral",
"start": 185,
"end": 204,
"loc": {
"start": {
"line": 5,
"column": 25
},
"end": {
"line": 5,
"column": 44
}
},
"extra": {
"rawValue": "../zones/IANAZone",
"raw": "'../zones/IANAZone'"
},
"value": "../zones/IANAZone"
}
},
{
"type": "ImportDeclaration",
"start": 206,
"end": 265,
"loc": {
"start": {
"line": 6,
"column": 0
},
"end": {
"line": 6,
"column": 59
}
},
"specifiers": [
{
"type": "ImportSpecifier",
"start": 215,
"end": 230,
"loc": {
"start": {
"line": 6,
"column": 9
},
"end": {
"line": 6,
"column": 24
}
},
"imported": {
"type": "Identifier",
"start": 215,
"end": 230,
"loc": {
"start": {
"line": 6,
"column": 9
},
"end": {
"line": 6,
"column": 24
},
"identifierName": "FixedOffsetZone"
},
"name": "FixedOffsetZone"
},
"local": {
"type": "Identifier",
"start": 215,
"end": 230,
"loc": {
"start": {
"line": 6,
"column": 9
},
"end": {
"line": 6,
"column": 24
},
"identifierName": "FixedOffsetZone"
},
"name": "FixedOffsetZone"
}
}
],
"source": {
"type": "StringLiteral",
"start": 238,
"end": 264,
"loc": {
"start": {
"line": 6,
"column": 32
},
"end": {
"line": 6,
"column": 58
}
},
"extra": {
"rawValue": "../zones/fixedOffsetZone",
"raw": "'../zones/fixedOffsetZone'"
},
"value": "../zones/fixedOffsetZone"
}
},
{
"type": "ImportDeclaration",
"start": 266,
"end": 305,
"loc": {
"start": {
"line": 7,
"column": 0
},
"end": {
"line": 7,
"column": 39
}
},
"specifiers": [
{
"type": "ImportSpecifier",
"start": 275,
"end": 283,
"loc": {
"start": {
"line": 7,
"column": 9
},
"end": {
"line": 7,
"column": 17
}
},
"imported": {
"type": "Identifier",
"start": 275,
"end": 283,
"loc": {
"start": {
"line": 7,
"column": 9
},
"end": {
"line": 7,
"column": 17
},
"identifierName": "Settings"
},
"name": "Settings"
},
"local": {
"type": "Identifier",
"start": 275,
"end": 283,
"loc": {
"start": {
"line": 7,
"column": 9
},
"end": {
"line": 7,
"column": 17
},
"identifierName": "Settings"
},
"name": "Settings"
}
}
],
"source": {
"type": "StringLiteral",
"start": 291,
"end": 304,
"loc": {
"start": {
"line": 7,
"column": 25
},
"end": {
"line": 7,
"column": 38
}
},
"extra": {
"rawValue": "../settings",
"raw": "'../settings'"
},
"value": "../settings"
}
},
{
"type": "ImportDeclaration",
"start": 306,
"end": 355,
"loc": {
"start": {
"line": 8,
"column": 0
},
"end": {
"line": 8,
"column": 49
}
},
"specifiers": [
{
"type": "ImportSpecifier",
"start": 315,
"end": 335,
"loc": {
"start": {
"line": 8,
"column": 9
},
"end": {
"line": 8,
"column": 29
}
},
"imported": {
"type": "Identifier",
"start": 315,
"end": 335,
"loc": {
"start": {
"line": 8,
"column": 9
},
"end": {
"line": 8,
"column": 29
},
"identifierName": "InvalidArgumentError"
},
"name": "InvalidArgumentError"
},
"local": {
"type": "Identifier",
"start": 315,
"end": 335,
"loc": {
"start": {
"line": 8,
"column": 9
},
"end": {
"line": 8,
"column": 29
},
"identifierName": "InvalidArgumentError"
},
"name": "InvalidArgumentError"
}
}
],
"source": {
"type": "StringLiteral",
"start": 343,
"end": 354,
"loc": {
"start": {
"line": 8,
"column": 37
},
"end": {
"line": 8,
"column": 48
}
},
"extra": {
"rawValue": "../errors",
"raw": "'../errors'"
},
"value": "../errors"
},
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * @private\n ",
"start": 357,
"end": 376,
"loc": {
"start": {
"line": 10,
"column": 0
},
"end": {
"line": 12,
"column": 3
}
}
}
]
},
{
"type": "ExportNamedDeclaration",
"start": 378,
"end": 5761,
"loc": {
"start": {
"line": 14,
"column": 0
},
"end": {
"line": 205,
"column": 1
}
},
"specifiers": [],
"source": null,
"declaration": {
"type": "ClassDeclaration",
"start": 385,
"end": 5761,
"loc": {
"start": {
"line": 14,
"column": 7
},
"end": {
"line": 205,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 391,
"end": 395,
"loc": {
"start": {
"line": 14,
"column": 13
},
"end": {
"line": 14,
"column": 17
},
"identifierName": "Util"
},
"name": "Util",
"leadingComments": null
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 396,
"end": 5761,
"loc": {
"start": {
"line": 14,
"column": 18
},
"end": {
"line": 205,
"column": 1
}
},
"body": [
{
"type": "ClassMethod",
"start": 400,
"end": 763,
"loc": {
"start": {
"line": 15,
"column": 2
},
"end": {
"line": 25,
"column": 3
}
},
"computed": false,
"key": {
"type": "Identifier",
"start": 407,
"end": 423,
"loc": {
"start": {
"line": 15,
"column": 9
},
"end": {
"line": 15,
"column": 25
},
"identifierName": "friendlyDuration"
},
"name": "friendlyDuration"
},
"static": true,
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 424,
"end": 432,
"loc": {
"start": {
"line": 15,
"column": 26
},
"end": {
"line": 15,
"column": 34
},
"identifierName": "duration"
},
"name": "duration"
}
],
"body": {
"type": "BlockStatement",
"start": 434,
"end": 763,
"loc": {
"start": {
"line": 15,
"column": 36
},
"end": {
"line": 25,
"column": 3
}
},
"body": [
{
"type": "IfStatement",
"start": 440,
"end": 759,
"loc": {
"start": {
"line": 16,
"column": 4
},
"end": {
"line": 24,
"column": 5
}
},
"test": {
"type": "CallExpression",
"start": 444,
"end": 467,
"loc": {
"start": {
"line": 16,
"column": 8
},
"end": {
"line": 16,
"column": 31
}
},
"callee": {
"type": "MemberExpression",
"start": 444,
"end": 457,
"loc": {
"start": {
"line": 16,
"column": 8
},
"end": {
"line": 16,
"column": 21
}
},
"object": {
"type": "Identifier",
"start": 444,
"end": 448,
"loc": {
"start": {
"line": 16,
"column": 8
},
"end": {
"line": 16,
"column": 12
},
"identifierName": "Util"
},
"name": "Util"
},
"property": {
"type": "Identifier",
"start": 449,
"end": 457,
"loc": {
"start": {
"line": 16,
"column": 13
},
"end": {
"line": 16,
"column": 21
},
"identifierName": "isNumber"
},
"name": "isNumber"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 458,
"end": 466,
"loc": {
"start": {
"line": 16,
"column": 22
},
"end": {
"line": 16,
"column": 30
},
"identifierName": "duration"
},
"name": "duration"
}
]
},
"consequent": {
"type": "BlockStatement",
"start": 469,
"end": 520,
"loc": {
"start": {
"line": 16,
"column": 33
},
"end": {
"line": 18,
"column": 5
}
},
"body": [
{
"type": "ReturnStatement",
"start": 477,
"end": 514,
"loc": {
"start": {
"line": 17,
"column": 6
},
"end": {
"line": 17,
"column": 43
}
},
"argument": {
"type": "CallExpression",
"start": 484,
"end": 513,
"loc": {
"start": {
"line": 17,
"column": 13
},
"end": {
"line": 17,
"column": 42
}
},
"callee": {
"type": "MemberExpression",
"start": 484,
"end": 503,
"loc": {
"start": {
"line": 17,
"column": 13
},
"end": {
"line": 17,
"column": 32
}
},
"object": {
"type": "Identifier",
"start": 484,
"end": 492,
"loc": {
"start": {
"line": 17,
"column": 13
},
"end": {
"line": 17,
"column": 21
},
"identifierName": "Duration"
},
"name": "Duration"
},
"property": {
"type": "Identifier",
"start": 493,
"end": 503,
"loc": {
"start": {
"line": 17,
"column": 22
},
"end": {
"line": 17,
"column": 32
},
"identifierName": "fromMillis"
},
"name": "fromMillis"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 504,
"end": 512,
"loc": {
"start": {
"line": 17,
"column": 33
},
"end": {
"line": 17,
"column": 41
},
"identifierName": "duration"
},
"name": "duration"
}
]
}
}
],
"directives": []
},
"alternate": {
"type": "IfStatement",
"start": 526,
"end": 759,
"loc": {
"start": {
"line": 18,
"column": 11
},
"end": {
"line": 24,
"column": 5
}
},
"test": {
"type": "BinaryExpression",
"start": 530,
"end": 558,
"loc": {
"start": {
"line": 18,
"column": 15
},
"end": {
"line": 18,
"column": 43
}
},
"left": {
"type": "Identifier",
"start": 530,
"end": 538,
"loc": {
"start": {
"line": 18,
"column": 15
},
"end": {
"line": 18,
"column": 23
},
"identifierName": "duration"
},
"name": "duration"
},
"operator": "instanceof",
"right": {
"type": "Identifier",
"start": 550,
"end": 558,
"loc": {
"start": {
"line": 18,
"column": 35
},
"end": {
"line": 18,
"column": 43
},
"identifierName": "Duration"
},
"name": "Duration"
}
},
"consequent": {
"type": "BlockStatement",
"start": 560,
"end": 590,
"loc": {
"start": {
"line": 18,
"column": 45
},
"end": {
"line": 20,
"column": 5
}
},
"body": [
{
"type": "ReturnStatement",
"start": 568,
"end": 584,
"loc": {
"start": {
"line": 19,
"column": 6
},
"end": {
"line": 19,
"column": 22
}
},
"argument": {
"type": "Identifier",
"start": 575,
"end": 583,
"loc": {
"start": {
"line": 19,
"column": 13
},
"end": {
"line": 19,
"column": 21
},
"identifierName": "duration"
},
"name": "duration"
}
}
],
"directives": []
},
"alternate": {
"type": "IfStatement",
"start": 596,
"end": 759,
"loc": {
"start": {
"line": 20,
"column": 11
},
"end": {
"line": 24,
"column": 5
}
},
"test": {
"type": "BinaryExpression",
"start": 600,
"end": 626,
"loc": {
"start": {
"line": 20,
"column": 15
},
"end": {
"line": 20,
"column": 41
}
},
"left": {
"type": "Identifier",
"start": 600,
"end": 608,
"loc": {
"start": {
"line": 20,
"column": 15
},
"end": {
"line": 20,
"column": 23
},
"identifierName": "duration"
},
"name": "duration"
},
"operator": "instanceof",
"right": {
"type": "Identifier",
"start": 620,
"end": 626,
"loc": {
"start": {
"line": 20,
"column": 35
},
"end": {
"line": 20,
"column": 41
},
"identifierName": "Object"
},
"name": "Object"
}
},
"consequent": {
"type": "BlockStatement",
"start": 628,
"end": 679,
"loc": {
"start": {
"line": 20,
"column": 43
},
"end": {
"line": 22,
"column": 5
}
},
"body": [
{
"type": "ReturnStatement",
"start": 636,
"end": 673,
"loc": {
"start": {
"line": 21,
"column": 6
},
"end": {
"line": 21,
"column": 43
}
},
"argument": {
"type": "CallExpression",
"start": 643,
"end": 672,
"loc": {
"start": {
"line": 21,
"column": 13
},
"end": {
"line": 21,
"column": 42
}
},
"callee": {
"type": "MemberExpression",
"start": 643,
"end": 662,
"loc": {
"start": {
"line": 21,
"column": 13
},
"end": {
"line": 21,
"column": 32
}
},
"object": {
"type": "Identifier",
"start": 643,
"end": 651,
"loc": {
"start": {
"line": 21,
"column": 13
},
"end": {
"line": 21,
"column": 21
},
"identifierName": "Duration"
},
"name": "Duration"
},
"property": {
"type": "Identifier",
"start": 652,
"end": 662,
"loc": {
"start": {
"line": 21,
"column": 22
},
"end": {
"line": 21,
"column": 32
},
"identifierName": "fromObject"
},
"name": "fromObject"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 663,
"end": 671,
"loc": {
"start": {
"line": 21,
"column": 33
},
"end": {
"line": 21,
"column": 41
},
"identifierName": "duration"
},
"name": "duration"
}
]
}
}
],
"directives": []
},
"alternate": {
"type": "BlockStatement",
"start": 685,
"end": 759,
"loc": {
"start": {
"line": 22,
"column": 11
},
"end": {
"line": 24,
"column": 5
}
},
"body": [
{
"type": "ThrowStatement",
"start": 693,
"end": 753,
"loc": {
"start": {
"line": 23,
"column": 6
},
"end": {
"line": 23,
"column": 66
}
},
"argument": {
"type": "NewExpression",
"start": 699,
"end": 752,
"loc": {
"start": {
"line": 23,
"column": 12
},
"end": {
"line": 23,
"column": 65
}
},
"callee": {
"type": "Identifier",
"start": 703,
"end": 723,
"loc": {
"start": {
"line": 23,
"column": 16
},
"end": {
"line": 23,
"column": 36
},
"identifierName": "InvalidArgumentError"
},
"name": "InvalidArgumentError"
},
"arguments": [
{
"type": "StringLiteral",
"start": 724,
"end": 751,
"loc": {
"start": {
"line": 23,
"column": 37
},
"end": {
"line": 23,
"column": 64
}
},
"extra": {
"rawValue": "Unknown duration argument",
"raw": "'Unknown duration argument'"
},
"value": "Unknown duration argument"
}
]
}
}
],
"directives": []
}
}
}
}
],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 767,
"end": 1184,
"loc": {
"start": {
"line": 27,
"column": 2
},
"end": {
"line": 37,
"column": 3
}
},
"computed": false,
"key": {
"type": "Identifier",
"start": 774,
"end": 790,
"loc": {
"start": {
"line": 27,
"column": 9
},
"end": {
"line": 27,
"column": 25
},
"identifierName": "friendlyDateTime"
},
"name": "friendlyDateTime"
},
"static": true,
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 791,
"end": 802,
"loc": {
"start": {
"line": 27,
"column": 26
},
"end": {
"line": 27,
"column": 37
},
"identifierName": "dateTimeish"
},
"name": "dateTimeish"
}
],
"body": {
"type": "BlockStatement",
"start": 804,
"end": 1184,
"loc": {
"start": {
"line": 27,
"column": 39
},
"end": {
"line": 37,
"column": 3
}
},
"body": [
{
"type": "IfStatement",
"start": 810,
"end": 1180,
"loc": {
"start": {
"line": 28,
"column": 4
},
"end": {
"line": 36,
"column": 5
}
},
"test": {
"type": "BinaryExpression",
"start": 814,
"end": 845,
"loc": {
"start": {
"line": 28,
"column": 8
},
"end": {
"line": 28,
"column": 39
}
},
"left": {
"type": "Identifier",
"start": 814,
"end": 825,
"loc": {
"start": {