/*****
Description: This function converts the date from one form to another.
Example: The input format is: 30 Oct 2006 the output format will be: 30/10/2006
Inculde this function int your globals.h
****/
gv_dateconvrt(const char* string,const char* output)
{
char* _lindate;
char separators[] = ". ";
char *token;
int i=0;
char cmm[2];
char mydate[10];
lr_save_string("",output);
_lindate=(char*)malloc(sizeof(string)*8);
strcpy(_lindate,string);
token = (char *)strtok(_lindate, separators); /* Get the first token */
if(!token) {
lr_output_message("No tokens found in string!");
return( -1 );
}
while( token != NULL ) { /* While valid tokens are returned */
do{
if(i==0){
lr_save_string(token,"dd");
i+=1;
break;
}
if(i==1){
lr_save_string(token,"mm");
i+=1;
break;
}
if(i==2){
lr_save_string(token,"yyyy");
i+=1;
break;
}
}while(1);
token = (char *)strtok(NULL, separators); /* Get the next token */
}//token while
free(_lindate);
if(strcmp("Jan",lr_eval_string("{mm}")) ==0){
strcpy(cmm,"01");
}
if(strcmp("Feb",lr_eval_string("{mm}")) ==0){
strcpy(cmm,"02");
}
if(strcmp("Mar",lr_eval_string("{mm}")) ==0){
strcpy(cmm,"03");
}
if(strcmp("Apr",lr_eval_string("{mm}")) ==0){
strcpy(cmm,"04");
}
if(strcmp("May",lr_eval_string("{mm}")) ==0){
strcpy(cmm,"05");
}
if(strcmp("Jun",lr_eval_string("{mm}")) ==0){
strcpy(cmm,"06");
}
if(strcmp("Jul",lr_eval_string("{mm}")) ==0){
strcpy(cmm,"07");
}
if(strcmp("Aug",lr_eval_string("{mm}")) ==0){
strcpy(cmm,"08");
}
if(strcmp("Sep",lr_eval_string("{mm}")) ==0){
strcpy(cmm,"09");
}
if(strcmp("Oct",lr_eval_string("{mm}")) ==0){
strcpy(cmm,"10");
}
if(strcmp("Nov",lr_eval_string("{mm}")) ==0){
strcpy(cmm,"11");
}
if(strcmp("Dec",lr_eval_string("{mm}")) ==0){
strcpy(cmm,"12");
}
sprintf(mydate,"%s/""%s/""%s",lr_eval_string("{dd}"),cmm,lr_eval_string("{yyyy}"));
//lr_output_message("mydate :%s",mydate);
lr_save_string(mydate,output);
return ;
}