*** ofmipd.c.org Sat Sep 5 11:33:37 1998 --- ofmipd.c Mon Jan 28 16:08:55 2002 *************** *** 1,3 **** --- 1,4 ---- + #include #include "commands.h" #include "sig.h" #include "auto_qmail.h" *************** *** 350,359 **** void smtp_data() { struct tai now; char *qqx; ! ! tai_now(&now); ! caltime_utc(&datastart.ct,&now,(int *) 0,(int *) 0); ! datastart.known = 1; if (!mess822_date(&datastamp,&datastart)) nomem(); if (!seenmail) { err_wantmail(); return; } --- 351,381 ---- void smtp_data() { struct tai now; char *qqx; ! struct tm *tmgmp, *tmlocp; ! time_t t, tdmy; ! ! /* ! tai_now(&now); ! caltime_utc(&datastart.ct,&now,(int *) 0,(int *) 0); ! datastart.known = 1; ! */ ! ! t = time(0); ! tmlocp = localtime(&t); ! ! datastart.ct.date.year = tmlocp->tm_year + 1900; ! datastart.ct.date.month = tmlocp->tm_mon + 1; ! datastart.ct.date.day = tmlocp->tm_mday; ! datastart.ct.hour = tmlocp->tm_hour; ! datastart.ct.minute = tmlocp->tm_min; ! datastart.ct.second = tmlocp->tm_sec; ! ! tmgmp = gmtime(&t); ! tdmy = mktime(tmgmp); ! ! datastart.ct.offset = (t-tdmy) / 60; ! datastart.known = 2; ! if (!mess822_date(&datastamp,&datastart)) nomem(); if (!seenmail) { err_wantmail(); return; } *** mess822_date.c.org Mon Jan 28 16:10:37 2002 --- mess822_date.c Mon Jan 28 16:07:20 2002 *************** *** 4,20 **** --- 4,37 ---- static char *montab[12] = { "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" }; + static char *wdaytab[7] = { + "Sun","Mon","Tue","Wed","Thu","Fri","Sat" + }; + + int dayOfWeek(int year, int month, int day) + { + if (month == 1 || month == 2) { + year--; + month += 12; + } + return (year + year/4 - year/100 + year/400 + (13*month+8)/5 + day) % 7; + } + int mess822_date(out,when) stralloc *out; mess822_time *when; { long i; + int wday; if (!stralloc_copys(out,"")) return 0; if (!when->known) return 1; + wday = dayOfWeek(when->ct.date.year,when->ct.date.month,when->ct.date.day); + if (!stralloc_cats(out,wdaytab[wday])) return 0; + if (!stralloc_cats(out,", ")) return 0; if (!stralloc_catint(out,when->ct.date.day)) return 0; if (!stralloc_cats(out," ")) return 0;