]> diplodocus.org Git - nmh/blobdiff - sbr/dtime.c
read_switch.c: Move interface declaration to own file.
[nmh] / sbr / dtime.c
index 56d874e0394079559e9b3449610363a3e5178896..3f8f7631d71fc5c0b9509920a191a7d0be3f8131 100644 (file)
@@ -5,10 +5,10 @@
  * complete copyright information.
  */
 
-#include <h/mh.h>   /* for snprintf() */
-#include <h/nmh.h>
-#include <h/utils.h>
-#include <h/tws.h>
+#include "h/mh.h"
+#include "h/nmh.h"
+#include "h/utils.h"
+#include "h/tws.h"
 #include <time.h>
 
 #if !defined(HAVE_STRUCT_TM_TM_GMTOFF)
@@ -118,7 +118,7 @@ dlocaltime (time_t *clock)
 
     tw.tw_clock = *clock;
 
-    return (&tw);
+    return &tw;
 }
 
 
@@ -165,7 +165,7 @@ dgmtime (time_t *clock)
 
     tw.tw_clock = *clock;
 
-    return (&tw);
+    return &tw;
 }
 
 
@@ -285,7 +285,8 @@ dasctime (struct tws *tw, int flags)
  * return the string representation of the numeric offset.
  */
 
-char *dtimezone(int offset, int flags)
+char *
+dtimezone(int offset, int flags)
 {
     static char buffer[sizeof "+3579139459"]; /* 2,147,483,648 / 60 = 35,791,394 */
     bool pos;
@@ -345,14 +346,17 @@ dmktime (struct tws *tw)
     while (--mon)
        result += dmsize[mon - 1];
     result += mday - 1;
-    result = 24 * result + hour;
-    result = 60 * result + min;
-    result = 60 * result + sec;
+    result *= 24; /* Days to hours. */
+    result += hour;
+    result *= 60; /* Hours to minutes. */
+    result += min;
+    result *= 60; /* Minutes to seconds. */
+    result += sec;
     result -= 60 * tw->tw_zone;
     if (tw->tw_flags & TW_DST)
-       result -= 60 * 60;
+       result -= 60 * 60; /* One hour. */
 
-    return (tw->tw_clock = result);
+    return tw->tw_clock = result;
 }
 
 
@@ -405,6 +409,6 @@ twsort (struct tws *tw1, struct tws *tw2)
     if (tw2->tw_clock == 0)
        dmktime (tw2);
 
-    return ((c1 = tw1->tw_clock) > (c2 = tw2->tw_clock) ? 1
-           : c1 == c2 ? 0 : -1);
+    return (c1 = tw1->tw_clock) > (c2 = tw2->tw_clock) ? 1
+           : c1 == c2 ? 0 : -1;
 }