Given that we can’t store dates ‘on’ a link, how might we approach this. Well the moving part is the person. So if we make a Dictionary attribute (which I’ll call $TimeDict) for a persons we can store when where they worked/lived/etc. using the location as the key and having as its value a list of the start and end dates at that place.
Here we see† such data for persons ‘A’ and ‘B’ stored when they worked at company ‘X’. In using column view just to make it easier to see both note’s data:
I’m only showing 2 people and each only has info for one company, but hopefully you can see how, we could add extra dictionary keys as needed for company ‘Y’, or ‘home1’, ‘school2’.
Now, some code:
// assumption: a date must not be 'never'
var:list vList1;
var:list vList2;
vList1 = $TimeDict("A")["X"];
vList2 = $TimeDict("B")["X"];
var:list vListBegin;
var:list vListEnd;
vListBegin = date(vList1[0]);
vListBegin += date(vList2[0]);
vListBegin = vListBegin.sort;
vListEnd = date(vList1[1]);
vListEnd += date(vList2[1]);
vListEnd = vListEnd.sort;
// get latest begin date
var:date vEarliest = vListBegin[1];
// get earliest end date
var:date vLatest = vListEnd[0];
$Text = "Earliest co-occurrence: " + vEarliest.format("L")+"\n";
$Text += "Latest co-occurrence: " + vLatest.format("L")+"\n";
and, tada … we have the possible dates when A and B were both working at X.
Don’t worry about the code as likely you’ll put this in a function once done so how much/little code is kept out of view. Of course, you could build from this so you get the data for N different people and come up with the period when all could have been at that place. for production you’d also want to test /report if there was no co-occurrence period.
But, I think this gives you a scalable approach and which requires no new features. Note:
- If date values might be
"never"
(unknown/missing) you might need more careful testing as you go - Be careful as you move dates from String-type to Date-type data and vice versa.
Still, HTH.
Here is my very simple text doc. the action code is currently in the $Edict for note “Test”: co-occurrence1.tbx (128.0 KB)
†. … where { }
indicates a Dictionary-type data object and [ ]
indicates a List-type data object. dictionary key values can be lists or even nested dictionaries.