A date increment function for fixing the bug of the vendor CDR web page of the billing interface
Download the C program [c], [txt] (129 KB).
Compile the program:
You can run the program providing the date and the increment as arguments. If you enter erroneous values, corresponding error message will be displayed:
Examples of normal execution are below:
The date increment C function can be compiled with and directly used from another program:
int dayinc(int y1, char m1, char d1, int *y2, char *m2, char *d2, int inc)
{
int i;
for(i=0;i<elements;i++)
if(days[i].y==y1 && days[i].m==m1 && days[i].d==d1)
break;
if(!(i<elements))
return 1;
if(!(i+inc>=0 && i+inc<elements))
return 2;
*y2=days[i+inc].y;
*m2=days[i+inc].m;
*d2=days[i+inc].d;
return 0;
}
The dates are not computed analytically. A wide continuous range of days is statically stored in the C program. The range is generated in an excel file [xls].
* * *