summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2011-03-04 10:12:27 +0100
committerLukas Fleischer <calcurse@cryptocrack.de>2011-03-04 10:12:27 +0100
commitd42d07ef6948e612452ceb77bb00008b5b7f10be (patch)
tree2cf10c1e81d584d6ab5a928e2f3e090a0e1c38ca
parentfdcfd74823beace1efbb01202e63e033755a8308 (diff)
downloadcalcurse-d42d07ef6948e612452ceb77bb00008b5b7f10be.tar.gz
calcurse-d42d07ef6948e612452ceb77bb00008b5b7f10be.zip
Simplify date_sec2date_str() in "utils.c".
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
-rw-r--r--src/utils.c17
1 files 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. */