/* * rfctime: show the date in a form amicable to mail * dow mon dom hh:mm TZ year */ #include "news.h" #include #if ATARIST #include #endif #if OS2 #include #endif static char *dow[] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" }; static char *mon[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; #if ATARIST struct clock { int yr; int mo; int dy; int hr; int mn; } ; /* * julian_date() gives the number of days since 0ad */ long julian_date(time) register struct clock *time; { register long c, y, m, d; y = time->yr + 1900; /* year - 1900 */ m = time->mo; /* month, 0..11 */ d = time->dy; /* day, 1..31 */ if(m > 2) m -= 3L; else { m += 9L; y -= 1L; } c = y / 100L; y %= 100L; return ((146097L * c) >> 2) + ((1461L * y) >> 2) + (((153L * m) + 2) / 5) + d + 1721119L; } /* julian_date */ #endif /* * rfcdate() give the current date in a politically correct manner */ char * rfcdate() { static char tmbuf[40]; #if ATARIST struct clock hacktm; unsigned time, date; time = Tgettime(); date = Tgetdate(); hacktm.yr =((date&0xFE00) >> 9)+80; hacktm.mo = (date&0x01E0) >> 5; hacktm.dy = (date&0x001F); hacktm.hr = (time&0xF800)>> 11; hacktm.mn = (time&0x07E0)>> 5; sprintf(tmbuf, "%s %s %2d %2d:%02d %s %d", dow[julian_date(&hacktm)%7], mon[hacktm.mo-1], hacktm.dy, hacktm.hr, hacktm.mn, TZ, 1900+hacktm.yr); #endif #if OS2 DATETIME now; DosGetDateTime(&now); sprintf(tmbuf, "%s %s %2d %2d:%02d %s %d", dow[now.weekday-1], mon[now.month-1], now.day, now.hours, now.minutes, TZ ? TZ : "" , now.year); #endif return tmbuf; } /* rfcdate() */