]> diplodocus.org Git - nmh/blobdiff - sbr/datetime.c
mhbuildsbr.c: Flip logic, moving goto to then-block; no need for else.
[nmh] / sbr / datetime.c
index 48f02d4501cc6448e4667ba0db17f15d1fc5f4ab..9ecff53cf8a014e15a6bec69da831716a0d03bb0 100644 (file)
@@ -10,6 +10,7 @@
 #include <h/fmt_scan.h>
 #include "h/tws.h"
 #include "h/utils.h"
+#include "unquote.h"
 
 /*
  * This doesn't try to support all of the myriad date-time formats
@@ -63,7 +64,7 @@ parse_datetime (const char *datetime, const char *zone, int dst,
     int form_1 = 0;
     int items_matched;
 
-    memset(tws, 0, sizeof *tws);
+    ZERO(tws);
     items_matched =
         sscanf (datetime, "%4d%2d%2dT%2d%2d%2d%c",
                 &tws->tw_year, &tws->tw_mon, &tws->tw_mday,
@@ -95,7 +96,8 @@ parse_datetime (const char *datetime, const char *zone, int dst,
         set_dotw (tws);
         /* set_dotw() sets TW_SIMP.  Replace that with TW_SEXP so that
            dasctime() outputs the dotw before the date instead of after. */
-        tws->tw_flags &= ~TW_SDAY, tws->tw_flags |= TW_SEXP;
+        tws->tw_flags &= ~TW_SDAY;
+        tws->tw_flags |= TW_SEXP;
 
         /* For the call to dmktime():
            - don't need tw_yday
@@ -169,7 +171,7 @@ load_timezones (const contentline *clines) {
                 if (in_standard) { in_standard = 0; }
                 else if (in_daylight) { in_daylight = 0; }
                 if (parse_datetime (params->dtstart, params->offsetfrom,
-                                    in_daylight ? 1 : 0,
+                                    in_daylight,
                                     &tws) == OK) {
                     if (tws.tw_year >= 1970) {
                         /* dmktime() falls apart for, e.g., the year 1601. */
@@ -450,7 +452,7 @@ format_datetime (tzdesc_t timezones, const contentline *node) {
                     return NULL;
                 }
 
-                dst = dt[1] > transition[0]  ?  0  :  1;
+                dst = dt[1] <= transition[0];
             }
         }