azu / mdline

Markdown timeline format and toolkit.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

could timeline item set detail timestamp, like 2020-01-01T01:00

Colstuwjx opened this issue · comments

As the title said, shall we support timestamp level item, rather than date time level.
Thanks!

commented

Currently, parsing dates is limited.
Probably, we can fix this function and resolve this issue.

const singleDatePattern = /(^[\d-]{4,}):(.*)/;
const dateRangePattern = /(^[\d-]{4,})--([\d-]{4,}):(.*)/;
if (dateRangePattern.test(text)) {
const matches = text.match(dateRangePattern);
if (matches === null) {
throw new Error("Invalid matching: date range");
}
return {
beginDate: matches[1],
endDate: matches[2],
title: matches[3].trim()
};
} else if (singleDatePattern.test(text)) {
const matches = text.match(singleDatePattern);
if (matches === null) {
throw new Error("Invalid matching: date");
}
return {
beginDate: matches[1],
title: matches[2].trim()
};
} else return null;