mirror of
https://github.com/PeWu/topola-viewer.git
synced 2026-05-26 23:26:15 +00:00
Fix parsing dates and date ranges
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import Cookies from 'js-cookie';
|
import Cookies from 'js-cookie';
|
||||||
import {Date, JsonFam, JsonIndi} from 'topola';
|
import {Date, JsonFam, JsonIndi, DateOrRange} from 'topola';
|
||||||
import {GedcomData, TopolaData, normalizeGedcom} from './gedcom_util';
|
import {GedcomData, TopolaData, normalizeGedcom} from './gedcom_util';
|
||||||
import {GedcomEntry} from 'parse-gedcom';
|
import {GedcomEntry} from 'parse-gedcom';
|
||||||
|
|
||||||
@@ -241,6 +241,7 @@ export async function loadWikiTree(
|
|||||||
}
|
}
|
||||||
converted.add(person.Id);
|
converted.add(person.Id);
|
||||||
const indi = convertPerson(person);
|
const indi = convertPerson(person);
|
||||||
|
console.log(person, indi);
|
||||||
if (person.Spouses) {
|
if (person.Spouses) {
|
||||||
Object.values(person.Spouses).forEach((spouse) => {
|
Object.values(person.Spouses).forEach((spouse) => {
|
||||||
const famId = getFamilyId(person.Id, spouse.Id);
|
const famId = getFamilyId(person.Id, spouse.Id);
|
||||||
@@ -347,13 +348,13 @@ function convertPerson(person: Person): JsonIndi {
|
|||||||
* Parses a date in the format returned by WikiTree and converts in to
|
* Parses a date in the format returned by WikiTree and converts in to
|
||||||
* the format defined by Topola.
|
* the format defined by Topola.
|
||||||
*/
|
*/
|
||||||
function parseDate(date: string, dataStatus?: string) {
|
function parseDate(date: string, dataStatus?: string): DateOrRange | undefined {
|
||||||
if (!date) {
|
if (!date) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
const matchedDate = date.match(/(\d\d\d\d)-(\d\d)-(\d\d)/);
|
const matchedDate = date.match(/(\d\d\d\d)-(\d\d)-(\d\d)/);
|
||||||
if (!matchedDate) {
|
if (!matchedDate) {
|
||||||
return {text: date};
|
return {date: {text: date}};
|
||||||
}
|
}
|
||||||
const parsedDate: Date = {};
|
const parsedDate: Date = {};
|
||||||
if (matchedDate[1] !== '0000') {
|
if (matchedDate[1] !== '0000') {
|
||||||
@@ -366,10 +367,10 @@ function parseDate(date: string, dataStatus?: string) {
|
|||||||
parsedDate.day = ~~matchedDate[3];
|
parsedDate.day = ~~matchedDate[3];
|
||||||
}
|
}
|
||||||
if (dataStatus === 'after') {
|
if (dataStatus === 'after') {
|
||||||
return {dataRange: {from: parsedDate}};
|
return {dateRange: {from: parsedDate}};
|
||||||
}
|
}
|
||||||
if (dataStatus === 'before') {
|
if (dataStatus === 'before') {
|
||||||
return {dataRange: {to: parsedDate}};
|
return {dateRange: {to: parsedDate}};
|
||||||
}
|
}
|
||||||
if (dataStatus === 'guess') {
|
if (dataStatus === 'guess') {
|
||||||
parsedDate.qualifier = 'abt';
|
parsedDate.qualifier = 'abt';
|
||||||
|
|||||||
Reference in New Issue
Block a user