Reuse a variable in date_to_str(). It also appears to make a bit more
authorparasti <parasti@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Mon, 18 Sep 2006 20:56:31 +0000 (20:56 +0000)
committerparasti <parasti@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Mon, 18 Sep 2006 20:56:31 +0000 (20:56 +0000)
sense that way.

git-svn-id: https://s.snth.net/svn/neverball/trunk@564 78b8d119-cf0a-0410-b17c-f493084dd1d7

ball/demo.c

index 7147961..e0ef49e 100644 (file)
@@ -301,7 +301,6 @@ const char *date_to_str(time_t i)
 {
     static char str[MAXSTR];
     struct tm local, *utc;
-    time_t t;
 
     /* Replay date/time is stored as UTC.  The code below computes the actual
      * local time.  Needless to say, this is an ugly hack...
@@ -317,11 +316,11 @@ const char *date_to_str(time_t i)
     local.tm_min  += local.tm_min  - utc->tm_min ;
     local.tm_sec  += local.tm_sec  - utc->tm_sec ;
 
-    /* Normalize the values if they've gotten out of range. */
+    /* Normalize values. */
+    i = mktime(&local);
 
-    t = mktime(&local);
+    strftime(str, MAXSTR, "%c", localtime(&i));
 
-    strftime(str, MAXSTR, "%c", localtime(&t));
     return str;
 }