Nico Golde:
[apps/madmutt.git] / date.c
diff --git a/date.c b/date.c
index cc8e4e3..fda07a0 100644 (file)
--- a/date.c
+++ b/date.c
@@ -1,20 +1,15 @@
 /*
+ * Copyright notice from original mutt:
  * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
- * 
- *     This program is free software; you can redistribute it and/or modify
- *     it under the terms of the GNU General Public License as published by
- *     the Free Software Foundation; either version 2 of the License, or
- *     (at your option) any later version.
- * 
- *     This program is distributed in the hope that it will be useful,
- *     but WITHOUT ANY WARRANTY; without even the implied warranty of
- *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *     GNU General Public License for more details.
- * 
- *     You should have received a copy of the GNU General Public License
- *     along with this program; if not, write to the Free Software
- *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ *
+ * This file is part of mutt-ng, see http://www.muttng.org/.
+ * It's licensed under the GNU General Public License,
+ * please see the file GPL in the top level source directory.
+ */
+
+#if HAVE_CONFIG_H
+# include "config.h"
+#endif
 
 #include "mutt.h"
 #include <string.h>
@@ -29,11 +24,10 @@ static time_t compute_tz (time_t g, struct tm *utc)
 
   t = (((lt->tm_hour - utc->tm_hour) * 60) + (lt->tm_min - utc->tm_min)) * 60;
 
-  if ((yday = (lt->tm_yday - utc->tm_yday)))
-  {
+  if ((yday = (lt->tm_yday - utc->tm_yday))) {
     /* This code is optimized to negative timezones (West of Greenwich) */
-    if (yday == -1 ||  /* UTC passed midnight before localtime */
-       yday > 1)       /* UTC passed new year before localtime */
+    if (yday == -1 ||           /* UTC passed midnight before localtime */
+        yday > 1)               /* UTC passed new year before localtime */
       t -= 24 * 60 * 60;
     else
       t += 24 * 60 * 60;
@@ -61,7 +55,7 @@ time_t mutt_local_tz (time_t t)
 
 /* converts struct tm to time_t, but does not take the local timezone into
    account unless ``local'' is nonzero */
-time_t mutt_mktime (struct tm *t, int local)
+time_t mutt_mktime (struct tm * t, int local)
 {
   time_t g;
 
@@ -70,7 +64,7 @@ time_t mutt_mktime (struct tm *t, int local)
   };
 
   /* Compute the number of days since January 1 in the same year */
-  g = AccumDaysPerMonth [t->tm_mon % 12];
+  g = AccumDaysPerMonth[t->tm_mon % 12];
 
   /* The leap years are 1972 and every 4. year until 2096,
    * but this algoritm will fail after year 2099 */
@@ -104,9 +98,9 @@ time_t mutt_mktime (struct tm *t, int local)
 /* Return 1 if month is February of leap year, else 0 */
 static int isLeapYearFeb (struct tm *tm)
 {
-  if (tm->tm_mon == 1)
-  {
+  if (tm->tm_mon == 1) {
     int y = tm->tm_year + 1900;
+
     return (((y & 3) == 0) && (((y % 100) != 0) || ((y % 400) == 0)));
   }
   return (0);
@@ -119,66 +113,54 @@ void mutt_normalize_time (struct tm *tm)
   };
   int nLeap;
 
-  while (tm->tm_sec < 0)
-  {
+  while (tm->tm_sec < 0) {
     tm->tm_sec += 60;
     tm->tm_min--;
   }
-  while (tm->tm_sec >= 60)
-  {
+  while (tm->tm_sec >= 60) {
     tm->tm_sec -= 60;
     tm->tm_min++;
   }
-  while (tm->tm_min < 0)
-  {
+  while (tm->tm_min < 0) {
     tm->tm_min += 60;
     tm->tm_hour--;
   }
-  while (tm->tm_min >= 60)
-  {
+  while (tm->tm_min >= 60) {
     tm->tm_min -= 60;
     tm->tm_hour++;
   }
-  while (tm->tm_hour < 0)
-  {
+  while (tm->tm_hour < 0) {
     tm->tm_hour += 24;
     tm->tm_mday--;
   }
-  while (tm->tm_hour >= 24)
-  {
+  while (tm->tm_hour >= 24) {
     tm->tm_hour -= 24;
     tm->tm_mday++;
   }
   /* use loops on NNNdwmy user input values? */
-  while (tm->tm_mon < 0)
-  {
+  while (tm->tm_mon < 0) {
     tm->tm_mon += 12;
     tm->tm_year--;
   }
-  while (tm->tm_mon >= 12)
-  {
+  while (tm->tm_mon >= 12) {
     tm->tm_mon -= 12;
     tm->tm_year++;
   }
-  while (tm->tm_mday <= 0)
-  {
+  while (tm->tm_mday <= 0) {
     if (tm->tm_mon)
       tm->tm_mon--;
-    else
-    {
+    else {
       tm->tm_mon = 11;
       tm->tm_year--;
     }
     tm->tm_mday += DaysPerMonth[tm->tm_mon] + isLeapYearFeb (tm);
   }
-  while (tm->tm_mday > (DaysPerMonth[tm->tm_mon] + 
-       (nLeap = isLeapYearFeb (tm))))
-  {
+  while (tm->tm_mday > (DaysPerMonth[tm->tm_mon] +
+                        (nLeap = isLeapYearFeb (tm)))) {
     tm->tm_mday -= DaysPerMonth[tm->tm_mon] + nLeap;
     if (tm->tm_mon < 11)
       tm->tm_mon++;
-    else
-    {
+    else {
       tm->tm_mon = 0;
       tm->tm_year++;
     }