Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Colstuwjx opened this issue Feb 2, 2020 · 1 comment
Open

Comments

@Colstuwjx
Copy link

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

@azu
Copy link
Owner

azu commented Feb 3, 2020

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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants