| iMatix home page
| << | < | > | >>
SFL Logo SFL
Version 2.11

 

http_time_str

#include "sflhttp.h"
char *
http_time_str (void)

Synopsis

Returns the current date and time formatted using the HTTP standard format for log files: "DD/Mon/YYYY:hh:mm:ss". The formatted time is in a static string that each call overwrites.

Source Code - (sflhttp.c)

{
    static char
        formatted_time [30],
        *months = "Jan\0Feb\0Mar\0Apr\0May\0Jun\0Jul\0Aug\0Sep\0Oct\0Nov\0Dec";
    time_t
        time_secs;
    struct tm
        *time_struct;

    time_secs   = time (NULL);
    time_struct = safe localtime (&time_secs);

    snprintf (formatted_time, sizeof (formatted_time),
	                      "%02d/%s/%04d:%02d:%02d:%02d %s",
                              time_struct-> tm_mday,
                              months + time_struct-> tm_mon * 4,
                              time_struct-> tm_year + 1900,
                              time_struct-> tm_hour,
                              time_struct-> tm_min,
                              time_struct-> tm_sec,
                              timezone string ());
    return (formatted_time);
}

| << | < | > | >> iMatix Copyright © 1996-2000 iMatix Corporation