Closed tr00datp00nar closed 3 weeks ago
Hello again @seanlowe . so i also had a problem with dealing with this from legacy code. my work around to getting the it to work correctly was
getStartEndDates(event: any): [Date, Date] {
const getDate = (dateStr: string): Date => {
let date = dateStr?.replace(/(.*)-\d*$/g, '$1');
if (date && date[0] == '-') {
let dateComp = date.substring(1, date.length).split('-');
return new Date(+`-${dateComp[0]}`, +dateComp[1] - 1, +dateComp[2]);
} else {
return new Date(date);
}
};
let start = getDate(event.date);
let end = getDate(event.endDate);
return [start, end];
}
but mainly how the code itself is reading negative dates. But i believe legacy was just using string types for the dates. so there really anything telling it the -1000 should be before 1000 as "-" and nothing more than a typeface and not a operation.
if you want please take a look at my dev branch and that might be more of a help to you than me trying to explain it .
@ReconVirus I'll make a note to take a look at your dev branch, any particular spot you'd like to highlight?
As of right now, I'm still using string dates but unfortunately this puts a bit of a damper on just how custom dates can get due to limitations with vis-timeline. I am currently exploring other horizontal timeline solutions
@tr00datp00nar, It only took me 4 months..... but this is fixed in release 2.1.13
@ReconVirus, thanks for the tip, I took some of what you did as a starting point for the solution I eventually went with.
I have a timeline that ranges from -1000-00-00-00 to 0001-00-00-00. I am using the default sorting order (old => new) and padding (5) in obsidian settings
When rendering, the timeline sorts incorrectly.
Actual sort: -100 -250 -400 -750 -1000 0001
Expected sort: -1000 -750 -400 -250 -100 0001
I am using the html method of declaring events and all of my dates use the YYYY-MM-DD-HH format as in the example below:
Other timelines that aren't using negative dates do sort properly.