]> 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 ba64e4d4d9b82a1cd61b075f84c0fff8492244e9..9ecff53cf8a014e15a6bec69da831716a0d03bb0 100644 (file)
@@ -1,5 +1,4 @@
-/*
- * datetime.c -- functions for manipulating RFC 5545 date-time values
+/* datetime.c -- functions for manipulating RFC 5545 date-time values
  *
  * This code is Copyright (c) 2014, by the authors of nmh.
  * See the COPYRIGHT file in the root directory of the nmh
  *
  * This code is Copyright (c) 2014, by the authors of nmh.
  * See the COPYRIGHT file in the root directory of the nmh
@@ -11,6 +10,7 @@
 #include <h/fmt_scan.h>
 #include "h/tws.h"
 #include "h/utils.h"
 #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
 
 /*
  * This doesn't try to support all of the myriad date-time formats
@@ -64,7 +64,7 @@ parse_datetime (const char *datetime, const char *zone, int dst,
     int form_1 = 0;
     int items_matched;
 
     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,
     items_matched =
         sscanf (datetime, "%4d%2d%2dT%2d%2d%2d%c",
                 &tws->tw_year, &tws->tw_mon, &tws->tw_mday,
@@ -96,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. */
         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
 
         /* For the call to dmktime():
            - don't need tw_yday
@@ -170,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,
                 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. */
                                     &tws) == OK) {
                     if (tws.tw_year >= 1970) {
                         /* dmktime() falls apart for, e.g., the year 1601. */
@@ -321,9 +322,8 @@ rrule_clock (const char *rrule, const char *starttime, const char *zone,
 
 fail:
     if (clock == 0) {
 
 fail:
     if (clock == 0) {
-        admonish (NULL,
-                  "Unsupported RRULE format: %s, assume local timezone",
-                  rrule);
+        inform("Unsupported RRULE format: %s, assume local timezone, continuing...",
+           rrule);
     }
 
     return clock;
     }
 
     return clock;
@@ -371,7 +371,7 @@ format_datetime (tzdesc_t timezones, const contentline *node) {
 
     /* Find the corresponding tzdesc. */
     for (tz = timezones; dt_timezone && tz; tz = tz->next) {
 
     /* Find the corresponding tzdesc. */
     for (tz = timezones; dt_timezone && tz; tz = tz->next) {
-        /* Property parameter values are case insenstive (RFC 5545
+        /* Property parameter values are case insensitive (RFC 5545
            Sec. 2) and time zone identifiers are property parameters
            (RFC 5545 Sec. 3.8.2.4), though it would seem odd to use
            different case in the same file for identifiers that are
            Sec. 2) and time zone identifiers are property parameters
            (RFC 5545 Sec. 3.8.2.4), though it would seem odd to use
            different case in the same file for identifiers that are
@@ -452,7 +452,7 @@ format_datetime (tzdesc_t timezones, const contentline *node) {
                     return NULL;
                 }
 
                     return NULL;
                 }
 
-                dst = dt[1] > transition[0]  ?  0  :  1;
+                dst = dt[1] <= transition[0];
             }
         }
 
             }
         }