2.1.8.27 okutil_date_str_convert


Description

Convert to or convert from date string

Syntax

int okutil_date_str_convert( DoubleArray * pdDates, StringArray * psDates, LPCSTR lpcszFmt, bool bStrToDate = true )

Parameters

pdDates
[input/output] vector of doubles
psDates
[input/output] vector of strings
lpcszFmt
[input] date format string specification, like "yyyyMMdd"
bStrToDate
[input] true if psDates -> pdDates, false if pdDates -> psDates

Return

0 for success, > 0 return the array index+1 that failed to be converted, <0 for other errors

Examples

EX1

void ds_test()
{
    vector<string> vs;
    vs.Add("20200401");vs.Add("20200501");
    vector<double> vd;
    okutil_date_str_convert(&vd, &vs, "yyyyMMdd");
    vd += 1;//add one day
    vector<string> vs2;
    okutil_date_str_convert(&vd, &vs2, "yyyyMMdd", false);
    for(int ii = 0; ii < vs2.GetSize(); ii++)
        printf("%d: %s\n", ii+1, vs2[ii]);
}

Remark

See Also

Header to Included

origin.h

Reference