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.
Files changed (68) hide show
  1. package/.vscode/settings.json +15 -0
  2. package/README.md +246 -256
  3. package/dist/ToJSON/console.js +15 -12
  4. package/dist/ToJSON/console.js.map +1 -1
  5. package/dist/ToJSON/models/DefinitionCache.js.map +1 -1
  6. package/dist/ToJSON/models/LineParsingResult.js.map +1 -1
  7. package/dist/ToJSON/models/ParsedLine.js +1 -1
  8. package/dist/ToJSON/models/ParsedLine.js.map +1 -1
  9. package/dist/ToJSON/models/Parsing.js +8 -6
  10. package/dist/ToJSON/models/Parsing.js.map +1 -1
  11. package/dist/ToJSON/models/ParsingObject.js.map +1 -1
  12. package/dist/ToJSON/models/ParsingOptions.js.map +1 -1
  13. package/dist/ToJSON/models/ParsingPath.js.map +1 -1
  14. package/dist/ToJSON/models/ParsingResult.js.map +1 -1
  15. package/dist/ToJSON/models/StatisticLine.js.map +1 -1
  16. package/dist/ToJSON/models/Statistics.js +2 -2
  17. package/dist/ToJSON/models/Statistics.js.map +1 -1
  18. package/dist/ToJSON/models/Store.js +11 -11
  19. package/dist/ToJSON/models/Store.js.map +1 -1
  20. package/dist/ToJSON/models/TagDefinition.js +11 -11
  21. package/dist/ToJSON/models/TagDefinition.js.map +1 -1
  22. package/dist/ToJSON/parsing/lineHelper.js +8 -8
  23. package/dist/ToJSON/parsing/lineHelper.js.map +1 -1
  24. package/dist/ToJSON/parsing/lineValidation.js +6 -6
  25. package/dist/ToJSON/parsing/lineValidation.js.map +1 -1
  26. package/dist/ToJSON/parsing/parseDate.js +84 -84
  27. package/dist/ToJSON/parsing/parseDate.js.map +1 -1
  28. package/dist/ToJSON/parsing/parseLine.js +8 -8
  29. package/dist/ToJSON/parsing/parseLine.js.map +1 -1
  30. package/dist/ToJSON/parsing/parsing.js +17 -17
  31. package/dist/ToJSON/parsing/parsing.js.map +1 -1
  32. package/dist/ToJSON/parsing/processLine.js +18 -18
  33. package/dist/ToJSON/parsing/processLine.js.map +1 -1
  34. package/dist/ToJSON/processing/manipulateValues.js +9 -10
  35. package/dist/ToJSON/processing/manipulateValues.js.map +1 -1
  36. package/dist/ToJSON/processing/result.js +87 -80
  37. package/dist/ToJSON/processing/result.js.map +1 -1
  38. package/dist/common.js +5 -5
  39. package/dist/common.js.map +1 -1
  40. package/dist/console.js +4 -4
  41. package/dist/console.js.map +1 -1
  42. package/dist/index.js.map +1 -1
  43. package/options/version551.yaml +303 -296
  44. package/package.json +10 -5
  45. package/src/ToJSON/console.ts +67 -67
  46. package/src/ToJSON/models/DefinitionCache.ts +7 -7
  47. package/src/ToJSON/models/LineParsingResult.ts +7 -7
  48. package/src/ToJSON/models/ParsedLine.ts +35 -35
  49. package/src/ToJSON/models/Parsing.ts +45 -41
  50. package/src/ToJSON/models/ParsingObject.ts +16 -16
  51. package/src/ToJSON/models/ParsingOptions.ts +41 -41
  52. package/src/ToJSON/models/ParsingPath.ts +7 -7
  53. package/src/ToJSON/models/ParsingResult.ts +10 -10
  54. package/src/ToJSON/models/StatisticLine.ts +16 -16
  55. package/src/ToJSON/models/Statistics.ts +63 -63
  56. package/src/ToJSON/models/Store.ts +106 -108
  57. package/src/ToJSON/models/TagDefinition.ts +123 -122
  58. package/src/ToJSON/parsing/lineHelper.ts +21 -21
  59. package/src/ToJSON/parsing/lineValidation.ts +39 -40
  60. package/src/ToJSON/parsing/parseDate.ts +280 -286
  61. package/src/ToJSON/parsing/parseLine.ts +33 -33
  62. package/src/ToJSON/parsing/parsing.ts +134 -141
  63. package/src/ToJSON/parsing/processLine.ts +112 -109
  64. package/src/ToJSON/processing/manipulateValues.ts +52 -53
  65. package/src/ToJSON/processing/result.ts +247 -241
  66. package/src/common.ts +14 -14
  67. package/src/console.ts +7 -8
  68. 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 "dayjs/plugin/objectSupport";
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
- lastDate = {};
33
- lastConfig = new ConvertToDate();
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
- if (!value) {
45
- return;
46
- }
44
+ if (!value) {
45
+ return;
46
+ }
47
47
 
48
- // if last date was not converted
49
- let lastDateValue = objectPath.get(lastDate, lastConfig.Value);
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
- let timeSplit = split(value, ":");
56
- let lastDateAsObject = dayjs(lastDateValue);
51
+ if (!(lastDateValue instanceof Date)) {
52
+ return value;
53
+ }
57
54
 
58
- if (timeSplit.length === 1){
59
- // not possible
60
- return value;
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 (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());
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
- return value;
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
- if (!value) {
93
- return;
94
- }
92
+ if (!value) {
93
+ return;
94
+ }
95
95
 
96
- let internValue = trim(toLower(value));
97
- let parsedObject = { };
98
- lastConfig = config;
99
- objectPath.set(parsedObject, config.Original, value);
96
+ let internValue = trim(toLower(value));
97
+ let parsedObject = {};
98
+ lastConfig = config;
99
+ objectPath.set(parsedObject, config.Original, value);
100
100
 
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));
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
- lastDate = parsedObject;
108
- return parsedObject;
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
- // TO
119
- if (startsWith(internValue, "to")){
120
- objectPath.set(parsedObject, config.To, ParseDate(trimStart(internValue, "to "), config));
121
- lastDate = parsedObject;
122
- return parsedObject;
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
- // 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));
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
- lastDate = parsedObject;
132
- return parsedObject;
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
- 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
- }
158
- else if (julian) {
159
- date = trim(julian[2]);
160
- calendarType = "Julian";
161
- }
162
- else if (hebrew) {
163
- date = trim(hebrew[2]);
164
- calendarType = "Hebrew";
165
- }
166
- else if (date.match(/(@#.*@) (.*)/)) {
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
- let markerRegex = /(abt |cal |est |aft |bef |int )(.*)/;
172
- let groups = date.match(markerRegex);
168
+ let markerRegex = /(abt |cal |est |aft |bef |int )(.*)/;
169
+ let groups = date.match(markerRegex);
173
170
 
174
- if (calendarType) {
175
- objectPath.set(result, config.Calendar, calendarType);
176
- }
171
+ if (calendarType) {
172
+ objectPath.set(result, config.Calendar, calendarType);
173
+ }
177
174
 
178
- // no marker
179
- if (!groups) {
180
- // single date, mark as between with from - to if not an exact date
181
- if (markAsBetweenIfNotExact) {
182
- let internResult = {} as any;
183
- ConvertStringToDate(date, internResult, config, calendarType);
184
-
185
- let hasYear = objectPath.get(internResult, config.HasYear);
186
- let hasMonth = objectPath.get(internResult, config.HasMonth);
187
- let hasDay = objectPath.get(internResult, config.HasDay);
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
- ConvertStringToDate(date, result, config, calendarType);
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
- while (groups != null && groups.length === 3) {
244
- let marker:string = groups[1];
245
- let dateContent:string = groups[2];
233
+ ConvertStringToDate(date, result, config, calendarType);
234
+ return result;
235
+ }
246
236
 
247
- SetMarker(marker, result, config);
237
+ while (groups != null && groups.length === 3) {
238
+ let marker: string = groups[1];
239
+ let dateContent: string = groups[2];
248
240
 
249
- if (trim(marker) === "int") {
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
- let oldGroups = fclone(groups);
256
- groups = dateContent.match(markerRegex);
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
- if (!groups) {
259
- groups = oldGroups;
260
- break;
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
- ConvertStringToDate(trim(groups[2]), result, config, calendarType);
265
- return result;
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
- switch(trim(marker)) {
270
- case "abt":
271
- objectPath.set(result, config.About, true);
272
- break;
273
- case "cal":
274
- objectPath.set(result, config.Calculated, true);
275
- break;
276
- case "est":
277
- objectPath.set(result, config.Estimated, true);
278
- break;
279
- case "aft":
280
- objectPath.set(result, config.After, true);
281
- break;
282
- case "bef":
283
- objectPath.set(result, config.Before, true);
284
- break;
285
- case "int":
286
- objectPath.set(result, config.Interpreted, true);
287
- break;
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
- let newDateString = split(CalendarConverter.fromJulianToGregorian(date.get("year"), date.get("month"), date.get("date")), "-");
293
- date = date.set("year", toNumber(newDateString[0]));
294
- date = date.set("month", toNumber(newDateString[1]));
295
- date = date.set("date", toNumber(newDateString[2]));
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
- return date;
291
+ return date;
298
292
  }
299
-
293
+
300
294
  /* istanbul ignore next */ // not completly tested
301
295
  function ConvertShortMonthToFullMonth(shortMonth: string) {
302
- switch(trim(shortMonth)) {
303
- case "tsh":
304
- return "Tishrei";
305
- case "csh":
306
- return "Cheshvan";
307
- case "ksl":
308
- return "Kislev";
309
- case "tvt":
310
- return "Tevet";
311
- case "shv":
312
- return "Shvat";
313
- case "adr":
314
- return "Adar 1";
315
- case "ads":
316
- return "Adar 2";
317
- case "nsn":
318
- return "Nisan";
319
- case "iyr":
320
- return "Iyyar";
321
- case "svn":
322
- return "Sivan";
323
- case "tmz":
324
- return "Tamuz";
325
- case "aav":
326
- return "Av";
327
- case "ell":
328
- return "Elul";
329
- }
330
-
331
- return "";
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
- let splitDate = split(date, " ");
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
- if (calendarType === "Julian") {
359
- dateValue = ConvertFromJulian(dateValue);
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
- objectPath.set(result, config.Value, dateValue.toDate());
363
- return;
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
- if (splitDate.length === 2) {
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
- if (calendarType === "Hebrew") {
373
- let hDate = new hebcal.HDate(`1 ${ConvertShortMonthToFullMonth(splitDate[0])} ${splitDate[1]}`);
374
- objectPath.set(result, config.Value, hDate.greg());
375
- return;
376
- }
352
+ if (calendarType === 'Julian') {
353
+ dateValue = ConvertFromJulian(dateValue);
354
+ }
377
355
 
378
- let dateValue = dayjs(`${upperFirst(splitDate[0])}-${splitDate[1]}`, 'MMM-YYYY');
356
+ objectPath.set(result, config.Value, dateValue.toDate());
357
+ return;
358
+ }
379
359
 
380
- if (calendarType === "Julian") {
381
- dateValue = ConvertFromJulian(dateValue);
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, true);
364
+ objectPath.set(result, config.HasDay, false);
392
365
 
393
- if (calendarType === "Hebrew") {
394
- let hDate = new hebcal.HDate(`${splitDate[0]} ${ConvertShortMonthToFullMonth(splitDate[1])} ${splitDate[2]}`);
395
- objectPath.set(result, config.Value, hDate.greg());
396
- return;
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(`${splitDate[0]}-${upperFirst(splitDate[1])}-${splitDate[2]}`, 'D-MMM-YYYY');
372
+ let dateValue = dayjs(`${upperFirst(splitDate[0])}-${splitDate[1]}`, 'MMM-YYYY');
400
373
 
401
- if (calendarType === "Julian") {
402
- dateValue = ConvertFromJulian(dateValue);
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
+ }