Time comparison in wap_push_ppg.c
"Wilfried Goesgens" <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <[email protected]> |
hy, I've browsed through the source of the push gateway stuff, and found a real weird funktion parsing the time, comparing it step by step... is there any god reason why not just use strptime to parse the string to a tm struct, convert that with mktime to time_t, and just compare the two resulting longs? i don't know if the former function uses an maximum ofset... and the actualtime now shouldn't be put as tm, so the mktime wouldn't be nescessary, but i didn't want to make such a big change... I've made a cvs diff to the current cvs and mine changes, and i'd be glad if it could be committed to the tree... cvs diff wap_push_ppg.c Index: wap_push_ppg.c =================================================================== RCS file: /home/cvs/gateway/gw/wap_push_ppg.c,v retrieving revision 1.64 diff -r1.64 wap_push_ppg.c 2735c2735,2738 < --- > struct tm aftertime; > time_t after_T; > time_t now_T; > char *error; 2738c2741,2749 < --- > error=strptime(octstr_get_cstr(after),"%Y-%m-%dT%H:%M:%SZ",&aftertime); > if (NULL!=error ) > return 1; // the string wasn't parseable > after_T=mktime(&aftertime); > now_T=mktime(&now); > if (after_T<now_T) return 0; > else return 1; > > /* 2751,2752c2762,2763 < < return 0; --- > > return 0;*/ kind regards, Wilfried Goesgens