blade api and datetime
Posted in 2003
Topics: General Discussion
I wanted to extend the ifx server capability and to compose an UDR that can substruct two datetime fields and return an integer value of seconds my UDR is: mi_integer ts_dtsub(mi_datetime *t1, mi_datetime *t2) { intrvl_t i; mi_string *str; char str_t1[30],str_t2[30],str_intvl[30]; dtime_t time1,time2; char *delim; int dddd,hh,mm,ss; /* convert t1,t2 to string */ str=mi_datetime_to_string(t1); memcpy(str_t1,str,sizeof(str_t1)); str=mi_datetime_to_string(t2); memcpy(str_t2,str,sizeof(str_t2)); /* convert t1_str,t2_str to dtime_t */ dtcvasc(str_t1,&time1); dtcvasc(str_t2,&time2); /* substruct t2 from t1 */ dtsub(&time1, &time2, &i); /* convert interval value to string */ intoasc(&i, str_intvl); /* expected str format is "DDDD HH:MM:SS" */ dddd=atoi((const char*)strtok(str_intvl," ")); hh=atoi((const char*)strtok(NULL,":")); mm=atoi((const char*)strtok(NULL,":")); ss=atoi((const char*)strtok(NULL,":")); return (dddd*3600*24 + hh*3600 + mm*60 + ss); } I did lots of experiment but none worked. Every time I am getting an error. I dont know how to precide/solve the problem. I am willing to try other solution as well. Anybody help will be a bless Thanks