如何将天数添加到从关联函数捕获的自定义日期?

How to add number of days to a custom Date captured from Correlation function?

我正在寻找可以将几天添加到自定义日期(不是当前日期)的逻辑

下面是相关函数:

 web_reg_save_param("Recommended_Date",
            "LB=\"start\":\"",
            "RB/DIG=T##:##:##\",",
            "Ord=1",
            "Search=Body",
            LAST);

我想将 +21 天添加到 Recommended_Date 参数。我试过做下面的事情但没有成功

lr_save_datetime("%Y-%M-%D", lr_eval_string("{Recommended_Date}") + (ONE_DAY*21), "New_Date");

谁能帮帮我。

我们的一位工程师为您准备了这个例子:

int diff_days(char * dateString, char * dateFormat) {
    
int year, month, day; 
struct tm info;
double delta;
double days=0;

time_t today;

    time(&today);
    
    sscanf(dateString, dateFormat, &year, &month, &day);
    
    info.tm_year = year - 1900;
    info.tm_mon = month - 1;
    info.tm_mday = day;
//      info.tm_hour = 0;
//      info.tm_min = 0;
//      info.tm_sec = 0;
    info.tm_isdst = -1;

    mktime(&info);
    delta = difftime(mktime(&info),today);

    if (delta >= 0)  {
        days = difftime(mktime(&info),today)/ 86400.0 +1;
    } else {
        days = difftime(mktime(&info),today)/ 86400.0;
    }

    return (int)days;   
}

Action()
{
    
    int plus;
    
    lr_save_string("2020-09-01","D2");

    plus = diff_days(lr_eval_string("{D2}"),"%d-%d-%d");
    
    lr_save_datetime("%Y-%m-%d", DATE_NOW + ONE_DAY*(21+plus), "New_Date");
    

    lr_save_string("2020/04/05","D2");

    plus = diff_days(lr_eval_string("{D2}"),"%d/%d/%d");
    
    lr_save_datetime("%Y/%m/%d", DATE_NOW + ONE_DAY*(21+plus), "New_Date");    
    
    
    
    return 0;
}