home *** CD-ROM | disk | FTP | other *** search
-
- #include <time.h>
- #include <stddef.h>
- static char *days[]= {"Monday","Tuesday","Wednesday","Thursday","Friday",
- "Saturday","Sunday"
- };
- static char *mont[]= {"January","February","March","April","May","June",
- "July","August","September","October","November",
- "December"
- };
- main(argc)
- int argc; /* Command line option to include time */
- {
- register int i; /* Used to find the expanded month and day */
- char bufr[40]; /* A place to hold the date string */
- char cmon[10],cday[10],ctime[10]; /* Storage for the month,day, and time */
- int nday,nyear; /* Storage for the numeric day and year */
- struct tm *ptr; /* A pointer to a "time" structure */
- time_t lt;
-
- lt=time(NULL); /* Setup for "time" call */
- ptr=localtime(<); /* Get the system time from DOS */
- strcpy(bufr,asctime(ptr)); /* Place string in the buffer */
- sscanf(bufr,"%s %s %d %s %d",cday,cmon,&nday,ctime,&nyear);
-
- ctime[strlen(ctime)-3]='\0'; /* Strip off the hundreths of seconds */
- for(i=0;i<7;i++) /* Find the day of the week */
- if(strncmp(days[i],cday,3)==0)
- break;
- strcpy(cday,days[i]); /* And spell the whole thing out */
- for(i=0;i<12;i++) /* Find the month of the year */
- if(strncmp(mont[i],cmon,3)==0)
- break;
- strcpy(cmon,mont[i]); /* And spell the whole thing out */
- if(argc!=2) /* See if you wanted the time output */
- printf("%s %d, %d\t%s\n",cmon,nday,nyear,cday);
- else
- printf("%s %d, %d\t%s %s\n",cmon,nday,nyear,cday,ctime);
- }