Dang, that seems like a lot of work.
Standard C functions give you this ability.
char *printdate(void)
{
struct tm *tp;
static char date[80];
time_t thetime = time(NULL);
tp = localtime(&thetime);
sprintf(date, (char *)"%d/%d/%02d %d:%02d:%02d", 1 + tp->tm_mon,
tp->tm_mday,
tp->tm_year % 100, tp->tm_hour, tp->tm_min,tp->tm_sec);
return date;
}
Output: 2/5/04 12:01:31
>
> -----Original Message-----
> From: Dale Kingston [mailto:[EMAIL PROTECTED]
> Sent: Sunday, March 21, 2004 7:18 PM
> To: [email protected]; Cyhawk
>
> Well I didn't format mine the exact same way, but it's close enough...
> Should give you an example of how you could work it to format
> out how you like it.
>
> struct month_type
> {
> char *month;
> int month_n;
> };
> struct month_type month_table[] ={
> {"jan", 1},
> {"feb", 2},
> {"mar", 3},
> {"apr", 4},
> {"may", 5},
> {"jun", 6},
> {"jul", 7},
> {"aug", 8},
> {"sep", 9},
> {"oct", 10},
> {"nov", 11},
> {"dec", 12},
> {NULL, 0}
> };
> char *date_convert (char *date)
> {
> /*Thu Jan 3 23:30:41 2002*/
> char arg1[MSL], arg2[MSL], arg3[MSL], arg4[MSL],
> buf[MSL], *string;
> int day, i;
>
> date = one_argument(date, arg1);
> date = one_argument(date, arg2);
> date = one_argument(date, arg3);
> date = one_argument(date, arg4);
>
> day = atoi(arg3);
>
> for (i = 0; month_table[i].month != NULL; i++)
> if (!str_cmp(month_table[i].month, arg2))
> break;
>
>
> sprintf (buf, "%2d/%2d", month_table[i].month_n ?
> month_table[i].month_n :
> 0, day);
> string = buf;
>
> return string;
> }
>
> ----- Original Message -----
> From: "Cyhawk" <[EMAIL PROTECTED]>
> To: <[email protected]>
> Sent: Sunday, March 21, 2004 4:52 PM
> Subject: showing time
>
>
> > Hello everyone.. agian ;) *i seem to be the only person
> asking questions
> > lately ;)*
> > Im having a small problem, for my item generator, i wanted
> to log all
> items
> > created.
> > Anywho, ive set up the logging, however, im having problems
> with showing
> > the time it
> > was created proplerly. Ive looked through the mud code, and
> the net, and i
> > cant find
> > a function to print the the time in a format i want it in.
> > Something like month/day/year hour:minuite without a
> newline charater.
> > 03/22/04 12:22am
> >
> > Any help is appreciated.
> >
> > -Thri
> >
> >
> > --
> > ROM mailing list
> > [email protected]
> > http://www.rom.org/cgi-bin/mailman/listinfo/rom
>
>
> --
> ROM mailing list
> [email protected]
> http://www.rom.org/cgi-bin/mailman/listinfo/rom
>