这是执行该任务的递归文件生成器代码。基本方法是在必要的情况下进行替换,从值中的最后一个日期(最右边的单词)开始计算日期。这样,它就可以决定何时检查下一个值是否仍然是第一个范围的一部分,或者将第一个范围标记为已完成,并将焦点集中在其余值上。希望它能帮助别人。
Let(
countDates = ValueCount ( dates );
If (
countDates < 2 ; dates;
Let(
[
start_date = GetAsDate( LeftWords( GetValue ( dates ; 1 ); 1 ) );
date_1 = GetAsDate( RightWords( GetValue ( dates ; 1 ); 1 ) );
date_2 = GetAsDate( GetValue ( dates ; 2 ) );
date_3 = GetAsDate( GetValue ( dates ; 3 ) );
dv_1 = GetAsNumber( date_1 );
dv_2 = GetAsNumber( date_2 );
dv_3 = GetAsNumber( date_3 );
twoFollowsOne = (dv_2 = dv_1 + 1);
threeFollowsTwo = (dv_3 = dv_2 + 1)
];
Case(
countDates = 2;
if (
twoFollowsOne;
start_date & dash & date_2;
GetValue ( dates ; 1 ) & comma & date_2
);
threeFollowsTwo and twoFollowsOne;
CollapseDateList( start_date & dash & date_3 & ¶ & RightValues( dates; countDates - 3 ); comma; dash );
not threeFollowsTwo and twoFollowsOne;
start_date & dash & date_2 & comma & CollapseDateList( RightValues( dates; countDates - 2 ); comma; dash );
GetValue ( dates ; 1 ) & comma & CollapseDateList( RightValues( dates; countDates - 1 ); comma; dash )
)
)
)
)