Hi everyone. I hope the title makes sense: I am trying to achieve a consistent definition of dates when there is some information missing (eg. the precise day or month of a given event).
Consider Tinderbox default behavior when you introduce something into $StartDate or $EndDate:
– if you put "2020", the output will be "15/06/20, 00:00"
– if you put "10/2020", the output will be "01/10/20, 00:00"
– if you put "05/10/2020", the output will be 05/10/20, 17:21"
I am trying to make this more consistent (IMHO) by using two user-defined list-type key attributes ($PartialStartDate and $PartialEndDate) which get interpreted by a set of rules and produce my desired $StartDate and #EndDate as follows:
– if I put year only in $PartialStartDate, $StartDate gets assigned the first day of that year, at 00:00;
– if I put year only in $PartialEndtDate, $EndtDate gets assigned the last day of that year, at 23:59;
– if I put month and year only in $PartialStartDate, $StartDate gets assigned the first day of that month, at 00:00;
– if I put month and year only in $PartialEndtDate, $EndtDate gets assigned the last day of that month, at 23:59;
– if I put month, year and day in $PartialStartDate, $StartDate gets assigned that day/month/year, at 00:00;
– if I put month, year and day in $PartialEndtDate, $EndDate gets assigned that day/month/year, at 23:59;
(being list-type attributes, year, month and day are separated by ";" and not by "/")
Other rules state that:
– if the $PartialStartDate is empty, the $PartialEndDate is cleared as well (no end dates without start dates);
- $PartialEndDate gets assigned the content of $PartialStartDate, if empty; this allows, for example:
– you place 05/2020 in $PartialStartDate;
– 05/2020 gets automatically assigned to $PartialEndDate;
– $StartDate gets assigned "01/05/2020, 00:00" and $EndDate gets assigned "31/05/2020, 23:59";
– if needed, $PartialEndDate can be changed to other date, and $EndDate will be updated.
The rules are as follows:
Code:f ($PartialStartDate.count=3)
{
$StartDate = date($PartialStartDate.at(2) / $PartialStartDate.at(1) / $PartialStartDate.at(0) + ",00:00:00");
};
if ($PartialStartDate.count=2)
{
$StartDate = date($PartialStartDate.at(1) / $PartialStartDate.at(0) / 01 + ",00:00:00");
};
if ($PartialStartDate.count=1)
{
$StartDate = date($PartialStartDate.at(0) / 01 / 01 + ",00:00:00");
};
if ($PartialEndDate.count=3)
{
$EndDate = date($PartialEndDate.at(2) / $PartialEndDate.at(1) / $PartialEndDate.at(0) + ",23:59:59");
};
if ($PartialEndDate.count=2)
{
$EndDate = date($PartialEndDate.at(1) / $PartialEndDate.at(0) / 01 + ",23:59:59") + 1month - 1day;
};
if ($PartialEndDate.count=1)
{
$EndDate = date($PartialEndDate.at(0) / 12 / 31 + ",23:59:59");
};
if ($PartialEndDate="") {
$PartialEndDate=$PartialStartDate;
};
if ($PartialStartDate="") {
$PartialEndDate=;
$StartDate=;
};
if ($PartialEndDate="") {
$EndDate=;
};
i
I'm sharing with you the TBX file
https://www.dropbox.com/s/z7x0l2a0hcv3vak/broad_date_definition.tbx?dl=0so all critics are welcome! Namely:
– if Tinderbox has a native way of doing this and I didn't knew;
– if there's a more elegant way to write the set of rules;
– and a PROBLEM that I am having trouble sorting out: if I place "1949" in year, it gets interpreted as "2049"; but "1950" gets interpreted as "1950". I'd like years to be interpreted literally, with 4-digits ... trying but having no luck so far. So help appreciated to solve this one!

Thanks.
Bruno.