gedcom.json 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +15 -0
- package/README.md +246 -256
- package/dist/ToJSON/console.js +15 -12
- package/dist/ToJSON/console.js.map +1 -1
- package/dist/ToJSON/models/DefinitionCache.js.map +1 -1
- package/dist/ToJSON/models/LineParsingResult.js.map +1 -1
- package/dist/ToJSON/models/ParsedLine.js +1 -1
- package/dist/ToJSON/models/ParsedLine.js.map +1 -1
- package/dist/ToJSON/models/Parsing.js +8 -6
- package/dist/ToJSON/models/Parsing.js.map +1 -1
- package/dist/ToJSON/models/ParsingObject.js.map +1 -1
- package/dist/ToJSON/models/ParsingOptions.js.map +1 -1
- package/dist/ToJSON/models/ParsingPath.js.map +1 -1
- package/dist/ToJSON/models/ParsingResult.js.map +1 -1
- package/dist/ToJSON/models/StatisticLine.js.map +1 -1
- package/dist/ToJSON/models/Statistics.js +2 -2
- package/dist/ToJSON/models/Statistics.js.map +1 -1
- package/dist/ToJSON/models/Store.js +11 -11
- package/dist/ToJSON/models/Store.js.map +1 -1
- package/dist/ToJSON/models/TagDefinition.js +11 -11
- package/dist/ToJSON/models/TagDefinition.js.map +1 -1
- package/dist/ToJSON/parsing/lineHelper.js +8 -8
- package/dist/ToJSON/parsing/lineHelper.js.map +1 -1
- package/dist/ToJSON/parsing/lineValidation.js +6 -6
- package/dist/ToJSON/parsing/lineValidation.js.map +1 -1
- package/dist/ToJSON/parsing/parseDate.js +84 -84
- package/dist/ToJSON/parsing/parseDate.js.map +1 -1
- package/dist/ToJSON/parsing/parseLine.js +8 -8
- package/dist/ToJSON/parsing/parseLine.js.map +1 -1
- package/dist/ToJSON/parsing/parsing.js +17 -17
- package/dist/ToJSON/parsing/parsing.js.map +1 -1
- package/dist/ToJSON/parsing/processLine.js +18 -18
- package/dist/ToJSON/parsing/processLine.js.map +1 -1
- package/dist/ToJSON/processing/manipulateValues.js +9 -10
- package/dist/ToJSON/processing/manipulateValues.js.map +1 -1
- package/dist/ToJSON/processing/result.js +87 -80
- package/dist/ToJSON/processing/result.js.map +1 -1
- package/dist/common.js +5 -5
- package/dist/common.js.map +1 -1
- package/dist/console.js +4 -4
- package/dist/console.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/options/version551.yaml +303 -296
- package/package.json +10 -5
- package/src/ToJSON/console.ts +67 -67
- package/src/ToJSON/models/DefinitionCache.ts +7 -7
- package/src/ToJSON/models/LineParsingResult.ts +7 -7
- package/src/ToJSON/models/ParsedLine.ts +35 -35
- package/src/ToJSON/models/Parsing.ts +45 -41
- package/src/ToJSON/models/ParsingObject.ts +16 -16
- package/src/ToJSON/models/ParsingOptions.ts +41 -41
- package/src/ToJSON/models/ParsingPath.ts +7 -7
- package/src/ToJSON/models/ParsingResult.ts +10 -10
- package/src/ToJSON/models/StatisticLine.ts +16 -16
- package/src/ToJSON/models/Statistics.ts +63 -63
- package/src/ToJSON/models/Store.ts +106 -108
- package/src/ToJSON/models/TagDefinition.ts +123 -122
- package/src/ToJSON/parsing/lineHelper.ts +21 -21
- package/src/ToJSON/parsing/lineValidation.ts +39 -40
- package/src/ToJSON/parsing/parseDate.ts +280 -286
- package/src/ToJSON/parsing/parseLine.ts +33 -33
- package/src/ToJSON/parsing/parsing.ts +134 -141
- package/src/ToJSON/parsing/processLine.ts +112 -109
- package/src/ToJSON/processing/manipulateValues.ts +52 -53
- package/src/ToJSON/processing/result.ts +247 -241
- package/src/common.ts +14 -14
- package/src/console.ts +7 -8
- package/src/index.ts +3 -6
|
@@ -12,7 +12,7 @@ import objectPath from 'object-path';
|
|
|
12
12
|
import CalendarConverter from 'julian-gregorian';
|
|
13
13
|
import dayjs, { Dayjs } from 'dayjs';
|
|
14
14
|
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
15
|
-
import objectSupport from
|
|
15
|
+
import objectSupport from 'dayjs/plugin/objectSupport';
|
|
16
16
|
|
|
17
17
|
import ConvertToDate from '../models/converter/ConvertToDate';
|
|
18
18
|
import fclone from 'fclone';
|
|
@@ -20,17 +20,17 @@ import fclone from 'fclone';
|
|
|
20
20
|
dayjs.extend(customParseFormat);
|
|
21
21
|
dayjs.extend(objectSupport);
|
|
22
22
|
|
|
23
|
-
/** properties for merging time and date */
|
|
23
|
+
/** properties for merging time and date */
|
|
24
24
|
let lastDate: object, lastConfig: ConvertToDate;
|
|
25
25
|
let hebcal: any = require('hebcal');
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Clears informations that are needed to merge date and time
|
|
29
29
|
*
|
|
30
|
-
*/
|
|
30
|
+
*/
|
|
31
31
|
export function ClearDateTimeMergingInfos() {
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
lastDate = {};
|
|
33
|
+
lastConfig = new ConvertToDate();
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
@@ -39,46 +39,46 @@ export function ClearDateTimeMergingInfos() {
|
|
|
39
39
|
* @param value - The time text
|
|
40
40
|
* @param ownProperty - If defined it adds the time value as own property to the date object
|
|
41
41
|
* @returns The time value
|
|
42
|
-
*/
|
|
42
|
+
*/
|
|
43
43
|
export function ConvertTimeStringToObject(value: string, ownProperty?: string) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
if (!value) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (!(lastDateValue instanceof Date)) {
|
|
52
|
-
return value;
|
|
53
|
-
}
|
|
48
|
+
// if last date was not converted
|
|
49
|
+
let lastDateValue = objectPath.get(lastDate, lastConfig.Value);
|
|
54
50
|
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
if (!(lastDateValue instanceof Date)) {
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
57
54
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
let timeSplit = split(value, ':');
|
|
56
|
+
let lastDateAsObject = dayjs(lastDateValue);
|
|
57
|
+
|
|
58
|
+
if (timeSplit.length === 1) {
|
|
59
|
+
// not possible
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (timeSplit.length === 2 || timeSplit.length === 3) {
|
|
64
|
+
// hour:minute
|
|
65
|
+
let hour = toNumber(timeSplit[0]);
|
|
66
|
+
let min = toNumber(timeSplit[1]);
|
|
67
|
+
let sec = toNumber(timeSplit.length === 3 ? timeSplit[2] : 0);
|
|
68
|
+
if (isFinite(hour) && isFinite(min) && isFinite(sec) && hour > -1 && hour < 24 && min > -1 && min < 60 && sec > -1 && sec < 60) {
|
|
69
|
+
lastDateAsObject = lastDateAsObject.add(hour, 'hour');
|
|
70
|
+
lastDateAsObject = lastDateAsObject.add(min, 'minute');
|
|
71
|
+
lastDateAsObject = lastDateAsObject.add(sec, 'second');
|
|
72
|
+
objectPath.set(lastDate, lastConfig.Value, lastDateAsObject.toDate());
|
|
61
73
|
}
|
|
62
|
-
|
|
63
|
-
if (
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
let min = toNumber(timeSplit[1]);
|
|
67
|
-
let sec = toNumber(timeSplit.length === 3 ? timeSplit[2] : 0);
|
|
68
|
-
if (isFinite(hour) && isFinite(min) && isFinite(sec) && hour > -1 && hour < 24 && min > -1 && min < 60 && sec > - 1 && sec < 60) {
|
|
69
|
-
lastDateAsObject = lastDateAsObject.add(hour, "hour");
|
|
70
|
-
lastDateAsObject = lastDateAsObject.add(min, "minute");
|
|
71
|
-
lastDateAsObject = lastDateAsObject.add(sec, "second");
|
|
72
|
-
objectPath.set(lastDate, lastConfig.Value, lastDateAsObject.toDate());
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (!ownProperty) {
|
|
76
|
-
let lastDateOriginal = objectPath.get(lastDate, lastConfig.Original);
|
|
77
|
-
objectPath.set(lastDate, lastConfig.Original, `${lastDateOriginal} ${value}`);
|
|
78
|
-
}
|
|
74
|
+
|
|
75
|
+
if (!ownProperty) {
|
|
76
|
+
let lastDateOriginal = objectPath.get(lastDate, lastConfig.Original);
|
|
77
|
+
objectPath.set(lastDate, lastConfig.Original, `${lastDateOriginal} ${value}`);
|
|
79
78
|
}
|
|
79
|
+
}
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
return value;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
/**
|
|
@@ -87,54 +87,54 @@ export function ConvertTimeStringToObject(value: string, ownProperty?: string) {
|
|
|
87
87
|
* @param config - The parsing configuration
|
|
88
88
|
* @param value - The gedcom date string
|
|
89
89
|
* @returns An object with the JS date and other properties
|
|
90
|
-
*/
|
|
90
|
+
*/
|
|
91
91
|
export function ConvertDateStringToObject(config: ConvertToDate, value: string) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
if (!value) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
95
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
let internValue = trim(toLower(value));
|
|
97
|
+
let parsedObject = {};
|
|
98
|
+
lastConfig = config;
|
|
99
|
+
objectPath.set(parsedObject, config.Original, value);
|
|
100
100
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
101
|
+
// FROM - TO
|
|
102
|
+
let groups = internValue.match(/(from )(.*)( to )(.*)/);
|
|
103
|
+
if (groups && groups.length === 5) {
|
|
104
|
+
objectPath.set(parsedObject, config.From, ParseDate(groups[2], config));
|
|
105
|
+
objectPath.set(parsedObject, config.To, ParseDate(groups[4], config));
|
|
106
106
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
// FROM
|
|
112
|
-
if (startsWith(internValue, "from")){
|
|
113
|
-
objectPath.set(parsedObject, config.From, ParseDate(trimStart(internValue, "from "), config));
|
|
114
|
-
lastDate = parsedObject;
|
|
115
|
-
return parsedObject;
|
|
116
|
-
}
|
|
107
|
+
lastDate = parsedObject;
|
|
108
|
+
return parsedObject;
|
|
109
|
+
}
|
|
117
110
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
111
|
+
// FROM
|
|
112
|
+
if (startsWith(internValue, 'from')) {
|
|
113
|
+
objectPath.set(parsedObject, config.From, ParseDate(trimStart(internValue, 'from '), config));
|
|
114
|
+
lastDate = parsedObject;
|
|
115
|
+
return parsedObject;
|
|
116
|
+
}
|
|
124
117
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
118
|
+
// TO
|
|
119
|
+
if (startsWith(internValue, 'to')) {
|
|
120
|
+
objectPath.set(parsedObject, config.To, ParseDate(trimStart(internValue, 'to '), config));
|
|
121
|
+
lastDate = parsedObject;
|
|
122
|
+
return parsedObject;
|
|
123
|
+
}
|
|
130
124
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
125
|
+
// BETWEEN
|
|
126
|
+
groups = internValue.match(/(between )(.*)( and )(.*)/);
|
|
127
|
+
if (groups && groups.length === 5) {
|
|
128
|
+
objectPath.set(parsedObject, config.Between, ParseDate(groups[2], config));
|
|
129
|
+
objectPath.set(parsedObject, config.And, ParseDate(groups[4], config));
|
|
134
130
|
|
|
135
|
-
assignIn(parsedObject, ParseDate(internValue, config, true));
|
|
136
131
|
lastDate = parsedObject;
|
|
137
132
|
return parsedObject;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
assignIn(parsedObject, ParseDate(internValue, config, true));
|
|
136
|
+
lastDate = parsedObject;
|
|
137
|
+
return parsedObject;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
/**
|
|
@@ -146,189 +146,183 @@ export function ConvertDateStringToObject(config: ConvertToDate, value: string)
|
|
|
146
146
|
* @internal
|
|
147
147
|
*/
|
|
148
148
|
function ParseDate(date: string, config: ConvertToDate, markAsBetweenIfNotExact = false) {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
// unknown calender format
|
|
168
|
-
return result;
|
|
169
|
-
}
|
|
149
|
+
let calendarType = '';
|
|
150
|
+
let result = {};
|
|
151
|
+
let gregorian = date.match(/(@#dgregorian@)(.*)/);
|
|
152
|
+
let julian = date.match(/(@#djulian@)(.*)/);
|
|
153
|
+
let hebrew = date.match(/(@#dhebrew@)(.*)/);
|
|
154
|
+
|
|
155
|
+
if (gregorian) {
|
|
156
|
+
date = trim(gregorian[2]);
|
|
157
|
+
} else if (julian) {
|
|
158
|
+
date = trim(julian[2]);
|
|
159
|
+
calendarType = 'Julian';
|
|
160
|
+
} else if (hebrew) {
|
|
161
|
+
date = trim(hebrew[2]);
|
|
162
|
+
calendarType = 'Hebrew';
|
|
163
|
+
} else if (date.match(/(@#.*@) (.*)/)) {
|
|
164
|
+
// unknown calender format
|
|
165
|
+
return result;
|
|
166
|
+
}
|
|
170
167
|
|
|
171
|
-
|
|
172
|
-
|
|
168
|
+
let markerRegex = /(abt |cal |est |aft |bef |int )(.*)/;
|
|
169
|
+
let groups = date.match(markerRegex);
|
|
173
170
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
171
|
+
if (calendarType) {
|
|
172
|
+
objectPath.set(result, config.Calendar, calendarType);
|
|
173
|
+
}
|
|
177
174
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
if (hasYear && hasMonth && hasDay) {
|
|
190
|
-
assignIn(result, internResult);
|
|
191
|
-
return result;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
objectPath.set(internResult, config.HasYear, true);
|
|
195
|
-
objectPath.set(internResult, config.HasMonth, true);
|
|
196
|
-
objectPath.set(internResult, config.HasDay, true);
|
|
197
|
-
objectPath.set(result, config.Between, internResult);
|
|
198
|
-
|
|
199
|
-
// calculate to value
|
|
200
|
-
let and = { } as any;
|
|
201
|
-
let startDate = objectPath.get(internResult, config.Value);
|
|
202
|
-
if (!hasMonth) {
|
|
203
|
-
// last day of year
|
|
204
|
-
if (calendarType === "Hebrew") {
|
|
205
|
-
ConvertStringToDate(`1 nsn ${toNumber(date) + 1}`, and, config, calendarType);
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
208
|
-
ConvertStringToDate(`1 jan ${startDate.getFullYear() + 1}`, and, config, calendarType);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
if (calendarType === "Hebrew") {
|
|
213
|
-
let dateSplit = split(date, " ");
|
|
214
|
-
let nextMonth = new hebcal.Month(ConvertShortMonthToFullMonth(dateSplit[0]), toNumber(dateSplit[1])).next();
|
|
215
|
-
let andDate = new hebcal.HDate(`1 ${nextMonth.getName()} ${dateSplit[1]}`);
|
|
216
|
-
objectPath.set(and, config.Value, andDate.greg());
|
|
217
|
-
}
|
|
218
|
-
else {
|
|
219
|
-
// last day of month
|
|
220
|
-
let dateValue = dayjs(upperFirst(date), 'MMM YYYY').add(1, "month");
|
|
221
|
-
|
|
222
|
-
if (calendarType === "Julian") {
|
|
223
|
-
dateValue = ConvertFromJulian(dateValue);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
let andDate = dateValue.toDate();
|
|
227
|
-
objectPath.set(and, config.Value, andDate);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
objectPath.set(and, config.HasYear, true);
|
|
231
|
-
objectPath.set(and, config.HasMonth, true);
|
|
232
|
-
objectPath.set(and, config.HasDay, true);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
objectPath.set(result, config.And, and);
|
|
236
|
-
return result;
|
|
237
|
-
}
|
|
175
|
+
// no marker
|
|
176
|
+
if (!groups) {
|
|
177
|
+
// single date, mark as between with from - to if not an exact date
|
|
178
|
+
if (markAsBetweenIfNotExact) {
|
|
179
|
+
let internResult = {} as any;
|
|
180
|
+
ConvertStringToDate(date, internResult, config, calendarType);
|
|
181
|
+
|
|
182
|
+
let hasYear = objectPath.get(internResult, config.HasYear);
|
|
183
|
+
let hasMonth = objectPath.get(internResult, config.HasMonth);
|
|
184
|
+
let hasDay = objectPath.get(internResult, config.HasDay);
|
|
238
185
|
|
|
239
|
-
|
|
186
|
+
if (hasYear && hasMonth && hasDay) {
|
|
187
|
+
assignIn(result, internResult);
|
|
240
188
|
return result;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
objectPath.set(internResult, config.HasYear, true);
|
|
192
|
+
objectPath.set(internResult, config.HasMonth, true);
|
|
193
|
+
objectPath.set(internResult, config.HasDay, true);
|
|
194
|
+
objectPath.set(result, config.Between, internResult);
|
|
195
|
+
|
|
196
|
+
// calculate to value
|
|
197
|
+
let and = {} as any;
|
|
198
|
+
let startDate = objectPath.get(internResult, config.Value);
|
|
199
|
+
if (!hasMonth) {
|
|
200
|
+
// last day of year
|
|
201
|
+
if (calendarType === 'Hebrew') {
|
|
202
|
+
ConvertStringToDate(`1 nsn ${toNumber(date) + 1}`, and, config, calendarType);
|
|
203
|
+
} else {
|
|
204
|
+
ConvertStringToDate(`1 jan ${startDate.getFullYear() + 1}`, and, config, calendarType);
|
|
205
|
+
}
|
|
206
|
+
} else {
|
|
207
|
+
if (calendarType === 'Hebrew') {
|
|
208
|
+
let dateSplit = split(date, ' ');
|
|
209
|
+
let nextMonth = new hebcal.Month(ConvertShortMonthToFullMonth(dateSplit[0]), toNumber(dateSplit[1])).next();
|
|
210
|
+
let andDate = new hebcal.HDate(`1 ${nextMonth.getName()} ${dateSplit[1]}`);
|
|
211
|
+
objectPath.set(and, config.Value, andDate.greg());
|
|
212
|
+
} else {
|
|
213
|
+
// last day of month
|
|
214
|
+
let dateValue = dayjs(upperFirst(date), 'MMM YYYY').add(1, 'month');
|
|
215
|
+
|
|
216
|
+
if (calendarType === 'Julian') {
|
|
217
|
+
dateValue = ConvertFromJulian(dateValue);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
let andDate = dateValue.toDate();
|
|
221
|
+
objectPath.set(and, config.Value, andDate);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
objectPath.set(and, config.HasYear, true);
|
|
225
|
+
objectPath.set(and, config.HasMonth, true);
|
|
226
|
+
objectPath.set(and, config.HasDay, true);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
objectPath.set(result, config.And, and);
|
|
230
|
+
return result;
|
|
241
231
|
}
|
|
242
232
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
233
|
+
ConvertStringToDate(date, result, config, calendarType);
|
|
234
|
+
return result;
|
|
235
|
+
}
|
|
246
236
|
|
|
247
|
-
|
|
237
|
+
while (groups != null && groups.length === 3) {
|
|
238
|
+
let marker: string = groups[1];
|
|
239
|
+
let dateContent: string = groups[2];
|
|
248
240
|
|
|
249
|
-
|
|
250
|
-
// interpreted value, probably no real date
|
|
251
|
-
objectPath.set(result, config.Value, toUpper(groups[2]));
|
|
252
|
-
return result;
|
|
253
|
-
}
|
|
241
|
+
SetMarker(marker, result, config);
|
|
254
242
|
|
|
255
|
-
|
|
256
|
-
|
|
243
|
+
if (trim(marker) === 'int') {
|
|
244
|
+
// interpreted value, probably no real date
|
|
245
|
+
objectPath.set(result, config.Value, toUpper(groups[2]));
|
|
246
|
+
return result;
|
|
247
|
+
}
|
|
257
248
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
249
|
+
let oldGroups = fclone(groups);
|
|
250
|
+
groups = dateContent.match(markerRegex);
|
|
251
|
+
|
|
252
|
+
if (!groups) {
|
|
253
|
+
groups = oldGroups;
|
|
254
|
+
break;
|
|
262
255
|
}
|
|
256
|
+
}
|
|
263
257
|
|
|
264
|
-
|
|
265
|
-
|
|
258
|
+
ConvertStringToDate(trim(groups[2]), result, config, calendarType);
|
|
259
|
+
return result;
|
|
266
260
|
}
|
|
267
261
|
|
|
268
262
|
function SetMarker(marker: string, result: any, config: ConvertToDate) {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
263
|
+
switch (trim(marker)) {
|
|
264
|
+
case 'abt':
|
|
265
|
+
objectPath.set(result, config.About, true);
|
|
266
|
+
break;
|
|
267
|
+
case 'cal':
|
|
268
|
+
objectPath.set(result, config.Calculated, true);
|
|
269
|
+
break;
|
|
270
|
+
case 'est':
|
|
271
|
+
objectPath.set(result, config.Estimated, true);
|
|
272
|
+
break;
|
|
273
|
+
case 'aft':
|
|
274
|
+
objectPath.set(result, config.After, true);
|
|
275
|
+
break;
|
|
276
|
+
case 'bef':
|
|
277
|
+
objectPath.set(result, config.Before, true);
|
|
278
|
+
break;
|
|
279
|
+
case 'int':
|
|
280
|
+
objectPath.set(result, config.Interpreted, true);
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
289
283
|
}
|
|
290
284
|
|
|
291
285
|
function ConvertFromJulian(date: Dayjs) {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
286
|
+
let newDateString = split(CalendarConverter.fromJulianToGregorian(date.get('year'), date.get('month'), date.get('date')), '-');
|
|
287
|
+
date = date.set('year', toNumber(newDateString[0]));
|
|
288
|
+
date = date.set('month', toNumber(newDateString[1]));
|
|
289
|
+
date = date.set('date', toNumber(newDateString[2]));
|
|
296
290
|
|
|
297
|
-
|
|
291
|
+
return date;
|
|
298
292
|
}
|
|
299
|
-
|
|
293
|
+
|
|
300
294
|
/* istanbul ignore next */ // not completly tested
|
|
301
295
|
function ConvertShortMonthToFullMonth(shortMonth: string) {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
296
|
+
switch (trim(shortMonth)) {
|
|
297
|
+
case 'tsh':
|
|
298
|
+
return 'Tishrei';
|
|
299
|
+
case 'csh':
|
|
300
|
+
return 'Cheshvan';
|
|
301
|
+
case 'ksl':
|
|
302
|
+
return 'Kislev';
|
|
303
|
+
case 'tvt':
|
|
304
|
+
return 'Tevet';
|
|
305
|
+
case 'shv':
|
|
306
|
+
return 'Shvat';
|
|
307
|
+
case 'adr':
|
|
308
|
+
return 'Adar 1';
|
|
309
|
+
case 'ads':
|
|
310
|
+
return 'Adar 2';
|
|
311
|
+
case 'nsn':
|
|
312
|
+
return 'Nisan';
|
|
313
|
+
case 'iyr':
|
|
314
|
+
return 'Iyyar';
|
|
315
|
+
case 'svn':
|
|
316
|
+
return 'Sivan';
|
|
317
|
+
case 'tmz':
|
|
318
|
+
return 'Tamuz';
|
|
319
|
+
case 'aav':
|
|
320
|
+
return 'Av';
|
|
321
|
+
case 'ell':
|
|
322
|
+
return 'Elul';
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
return '';
|
|
332
326
|
}
|
|
333
327
|
|
|
334
328
|
/**
|
|
@@ -339,68 +333,68 @@ function ConvertShortMonthToFullMonth(shortMonth: string) {
|
|
|
339
333
|
* @internal
|
|
340
334
|
*/
|
|
341
335
|
function ConvertStringToDate(date: string, result: object, config: ConvertToDate, calendarType: string) {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
if (splitDate.length === 1) {
|
|
345
|
-
// year
|
|
346
|
-
objectPath.set(result, config.HasYear, true);
|
|
347
|
-
objectPath.set(result, config.HasMonth, false);
|
|
348
|
-
objectPath.set(result, config.HasDay, false);
|
|
349
|
-
|
|
350
|
-
if (calendarType === "Hebrew"){
|
|
351
|
-
let hDate = new hebcal.HDate(`1 Nisan ${splitDate[0]}`);
|
|
352
|
-
objectPath.set(result, config.Value, hDate.greg());
|
|
353
|
-
return;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
let dateValue = dayjs(splitDate[0], 'YYYY');
|
|
336
|
+
let splitDate = split(date, ' ');
|
|
357
337
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
338
|
+
if (splitDate.length === 1) {
|
|
339
|
+
// year
|
|
340
|
+
objectPath.set(result, config.HasYear, true);
|
|
341
|
+
objectPath.set(result, config.HasMonth, false);
|
|
342
|
+
objectPath.set(result, config.HasDay, false);
|
|
361
343
|
|
|
362
|
-
|
|
363
|
-
|
|
344
|
+
if (calendarType === 'Hebrew') {
|
|
345
|
+
let hDate = new hebcal.HDate(`1 Nisan ${splitDate[0]}`);
|
|
346
|
+
objectPath.set(result, config.Value, hDate.greg());
|
|
347
|
+
return;
|
|
364
348
|
}
|
|
365
349
|
|
|
366
|
-
|
|
367
|
-
// month and year
|
|
368
|
-
objectPath.set(result, config.HasYear, true);
|
|
369
|
-
objectPath.set(result, config.HasMonth, true);
|
|
370
|
-
objectPath.set(result, config.HasDay, false);
|
|
350
|
+
let dateValue = dayjs(splitDate[0], 'YYYY');
|
|
371
351
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
return;
|
|
376
|
-
}
|
|
352
|
+
if (calendarType === 'Julian') {
|
|
353
|
+
dateValue = ConvertFromJulian(dateValue);
|
|
354
|
+
}
|
|
377
355
|
|
|
378
|
-
|
|
356
|
+
objectPath.set(result, config.Value, dateValue.toDate());
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
379
359
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
objectPath.set(result, config.Value, dateValue.toDate());
|
|
385
|
-
return;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
// full date
|
|
360
|
+
if (splitDate.length === 2) {
|
|
361
|
+
// month and year
|
|
389
362
|
objectPath.set(result, config.HasYear, true);
|
|
390
363
|
objectPath.set(result, config.HasMonth, true);
|
|
391
|
-
objectPath.set(result, config.HasDay,
|
|
364
|
+
objectPath.set(result, config.HasDay, false);
|
|
392
365
|
|
|
393
|
-
if (calendarType ===
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
366
|
+
if (calendarType === 'Hebrew') {
|
|
367
|
+
let hDate = new hebcal.HDate(`1 ${ConvertShortMonthToFullMonth(splitDate[0])} ${splitDate[1]}`);
|
|
368
|
+
objectPath.set(result, config.Value, hDate.greg());
|
|
369
|
+
return;
|
|
397
370
|
}
|
|
398
371
|
|
|
399
|
-
let dateValue = dayjs(`${
|
|
372
|
+
let dateValue = dayjs(`${upperFirst(splitDate[0])}-${splitDate[1]}`, 'MMM-YYYY');
|
|
400
373
|
|
|
401
|
-
if (calendarType ===
|
|
402
|
-
|
|
374
|
+
if (calendarType === 'Julian') {
|
|
375
|
+
dateValue = ConvertFromJulian(dateValue);
|
|
403
376
|
}
|
|
404
377
|
|
|
405
|
-
objectPath.set(result, config.Value, dateValue.toDate());
|
|
406
|
-
|
|
378
|
+
objectPath.set(result, config.Value, dateValue.toDate());
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// full date
|
|
383
|
+
objectPath.set(result, config.HasYear, true);
|
|
384
|
+
objectPath.set(result, config.HasMonth, true);
|
|
385
|
+
objectPath.set(result, config.HasDay, true);
|
|
386
|
+
|
|
387
|
+
if (calendarType === 'Hebrew') {
|
|
388
|
+
let hDate = new hebcal.HDate(`${splitDate[0]} ${ConvertShortMonthToFullMonth(splitDate[1])} ${splitDate[2]}`);
|
|
389
|
+
objectPath.set(result, config.Value, hDate.greg());
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
let dateValue = dayjs(`${splitDate[0]}-${upperFirst(splitDate[1])}-${splitDate[2]}`, 'D-MMM-YYYY');
|
|
394
|
+
|
|
395
|
+
if (calendarType === 'Julian') {
|
|
396
|
+
dateValue = ConvertFromJulian(dateValue);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
objectPath.set(result, config.Value, dateValue.toDate());
|
|
400
|
+
}
|