From d42d07ef6948e612452ceb77bb00008b5b7f10be Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Fri, 4 Mar 2011 10:12:27 +0100 Subject: Simplify date_sec2date_str() in "utils.c". Signed-off-by: Lukas Fleischer --- src/utils.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/utils.c b/src/utils.c index ede1303..d08b83a 100644 --- a/src/utils.c +++ b/src/utils.c @@ -507,21 +507,16 @@ char * date_sec2date_str (long sec, char *datefmt) { struct tm *lt; - time_t t; - char *datestr; - - datestr = (char *) mem_calloc (BUFSIZ, sizeof (char)); + char *datestr = (char *) mem_calloc (BUFSIZ, sizeof (char)); if (sec == 0) (void)snprintf (datestr, BUFSIZ, "0"); - else - { - t = sec; - lt = localtime (&t); - strftime (datestr, BUFSIZ, datefmt, lt); - } + else { + lt = localtime ((time_t *)&sec); + strftime (datestr, BUFSIZ, datefmt, lt); + } - return (datestr); + return datestr; } /* Generic function to format date. */ -- cgit v1.2.3-70-g09d2