3 * Utility routines used by the SMS extraction programs.
13 /* Trim trailing spaces from a string by replacing one of them with a null.
33 /* return a "saved" copy of the string */
40 r = malloc(strlen(s) + 1);
47 /* ingres_date_and_time: passed a unix time_t, returns a string that ingres
48 * can parse to obtain that time.
51 static char *month_name[] = {
52 "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct",
57 char *ingres_date(), *ingres_time();
59 char *ingres_date_and_time(l)
62 char *ans = NULL, *date, *time;
64 if ((date = ingres_date(l)) && (time = ingres_time(l))) {
66 sprintf(buf, "%s %s", date, time);
84 if ((tm = localtime(&t)) == (struct tm *) NULL) {
89 sprintf(buf, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min,
103 if ((tm = localtime(&t)) == (struct tm *) NULL) {
108 sprintf(buf, "%02d-%3.3s-%04d", tm->tm_mday,
109 month_name[tm->tm_mon], 1900 + tm->tm_year);