#include #include "defs.h" private char MYFORMAT[] = "wmdy"; /* weekday month day year */ private char ERRORCHAR[] = "*"; private char date[ 26 ]; /* * Return a string containing an ascii date according to format. */ public char *GetDate( format ) /* format should look like "-Dwmy" */ char *format; { long theTime; char *theAscTime; char *i; char *weekday; char *month; char *day; char *hour; char *year; theTime = time( 0 ); theAscTime = ctime( &theTime ); weekday = theAscTime; month = 4 + theAscTime; day = 8 + theAscTime; hour = 11 + theAscTime; year = 20 + theAscTime; *(year + 4) = '\0'; *(year - 1) = '\0'; *(hour - 1) = '\0'; *(day - 1) = '\0'; *(month - 1) = '\0'; format = format + 2; if ( *format == '\0' ) format = MYFORMAT; for( *date ='\0' ; *format != '\0'; format++ ) { switch (*format) { case 'w': i = weekday; break; case 'd': i = day; break; case 'm': i = month; break; case 'y': i = year; break; case 'h': i = hour; break; default: i = ERRORCHAR; break; } strcat( date, i ); strcat( date, " " ); } strcat( date, "\0" ); return( date ); }