Update all #include directives to the currently preferred style.
[pspp-builds.git] / src / data / calendar.c
index ac37f86987341d7085d01990ba947ab1cd9cdecb..a2bb7e600004c6cd025c90e0c26641e12fe30ce0 100644 (file)
@@ -1,9 +1,28 @@
+/* PSPP - a program for statistical analysis.
+   Copyright (C) 2006, 2007, 2008, 2010, 2011 Free Software Foundation, Inc.
+
+   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 3 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, see <http://www.gnu.org/licenses/>. */
+
 #include <config.h>
-#include "calendar.h"
+
+#include "data/calendar.h"
+
 #include <assert.h>
 #include <stdbool.h>
-#include <data/settings.h>
-#include <data/val-type.h>
+
+#include "data/settings.h"
+#include "data/val-type.h"
 
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
@@ -52,13 +71,12 @@ raw_gregorian_to_offset (int y, int m, int d)
    Gregorian calendar.  Returns SYSMIS for dates before 14 Oct
    1582. */
 double
-calendar_gregorian_to_offset (int y, int m, int d,
-                              calendar_error_func *error, void *aux)
+calendar_gregorian_to_offset (int y, int m, int d, char **errorp)
 {
   /* Normalize year. */
   if (y >= 0 && y < 100)
     {
-      int epoch = get_epoch ();
+      int epoch = settings_get_epoch ();
       int century = epoch / 100 + (y < epoch % 100);
       y += century * 100;
     }
@@ -78,7 +96,9 @@ calendar_gregorian_to_offset (int y, int m, int d,
         }
       else
         {
-          error (aux, _("Month %d is not in acceptable range of 0 to 13."), m);
+          if (errorp != NULL)
+            *errorp = xasprintf (_("Month %d is not in acceptable range of "
+                                   "0 to 13."), m);
           return SYSMIS;
         }
     }
@@ -86,19 +106,24 @@ calendar_gregorian_to_offset (int y, int m, int d,
   /* Normalize day. */
   if (d < 0 || d > 31)
     {
-      error (aux, _("Day %d is not in acceptable range of 0 to 31."), d);
+      if (errorp != NULL)
+        *errorp = xasprintf (_("Day %d is not in acceptable range of "
+                               "0 to 31."), d);
       return SYSMIS;
     }
 
   /* Validate date. */
   if (y < 1582 || (y == 1582 && (m < 10 || (m == 10 && d < 15))))
     {
-      error (aux, _("Date %04d-%d-%d is before the earliest acceptable "
-                    "date of 1582-10-15."), y, m, d);
+      if (errorp != NULL)
+        *errorp = xasprintf (_("Date %04d-%d-%d is before the earliest "
+                               "acceptable date of 1582-10-15."), y, m, d);
       return SYSMIS;
     }
 
   /* Calculate offset. */
+  if (errorp != NULL)
+    *errorp = NULL;
   return raw_gregorian_to_offset (y, m, d);
 }