* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
+ * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
- * Library General Public License for more details.
+ * Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Library General Public
+ * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
+/*
+ * Modified by the GLib Team and others 1997-2000. See the AUTHORS
+ * file for a list of people on the GLib Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GLib at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
/*
* MT safe
*/
+#define DEBUG_MSG(x) /* */
+#ifdef G_ENABLE_DEBUG
+/* #define DEBUG_MSG(args) g_message args ; */
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "glib.h"
#include <time.h>
memset (d, 0x0, ndates*sizeof (GDate));
}
-G_LOCK_DECLARE_STATIC (g_date_global);
+G_LOCK_DEFINE_STATIC (g_date_global);
/* These are for the parser, output to the user should use *
* g_date_strftime () - this creates more never-freed memory to annoy
{
gchar num[4][NUM_LEN+1];
gint i;
- const gchar *s;
+ const guchar *s;
/* We count 4, but store 3; so we can give an error
* if there are 4.
}
#ifdef G_ENABLE_DEBUG
- g_message ("**GDate prepared a new set of locale-specific parse rules.");
+ DEBUG_MSG (("**GDate prepared a new set of locale-specific parse rules."));
i = 1;
while (i < 13)
{
- g_message (" %s %s", long_month_names[i], short_month_names[i]);
+ DEBUG_MSG ((" %s %s", long_month_names[i], short_month_names[i]));
++i;
}
if (using_twodigit_years)
- {
- g_message ("**Using twodigit years with cutoff year: %u", twodigit_start_year);
- }
+ DEBUG_MSG (("**Using twodigit years with cutoff year: %u", twodigit_start_year));
{
gchar *strings[3];
i = 0;
}
++i;
}
- g_message ("**Order: %s, %s, %s", strings[0], strings[1], strings[2]);
- g_message ("**Sample date in this locale: `%s'", buf);
+ DEBUG_MSG (("**Order: %s, %s, %s", strings[0], strings[1], strings[2]));
+ DEBUG_MSG (("**Sample date in this locale: `%s'", buf));
}
#endif
}
g_date_prepare_to_parse (str, &pt);
-#ifdef G_ENABLE_DEBUG
- g_message ("Found %d ints, `%d' `%d' `%d' and written out month %d",
- pt.num_ints, pt.n[0], pt.n[1], pt.n[2], pt.month);
-#endif
+ DEBUG_MSG (("Found %d ints, `%d' `%d' `%d' and written out month %d",
+ pt.num_ints, pt.n[0], pt.n[1], pt.n[2], pt.month));
if (pt.num_ints == 4)
}
#ifdef G_ENABLE_DEBUG
else
- g_message ("Rejected DMY %u %u %u", day, m, y);
+ DEBUG_MSG (("Rejected DMY %u %u %u", day, m, y));
#endif
G_UNLOCK (g_date_global);
}
GTime time)
{
time_t t = time;
- struct tm *tm;
+ struct tm tm;
g_return_if_fail (d != NULL);
- tm = localtime (&t);
+#ifdef HAVE_LOCALTIME_R
+ localtime_r (&t, &tm);
+#else
+ {
+ struct tm *ptm = localtime (&t);
+ g_assert (ptm);
+ memcpy ((void *) &tm, (void *) ptm, sizeof(struct tm));
+ }
+#endif
- if (tm)
- {
- d->julian = FALSE;
-
- d->month = tm->tm_mon + 1;
- d->day = tm->tm_mday;
- d->year = tm->tm_year + 1900;
-
- g_return_if_fail (g_date_valid_dmy (d->day, d->month, d->year));
-
- d->dmy = TRUE;
- }
- else
- {
- g_date_clear (d, 1);
- }
+ d->julian = FALSE;
+
+ d->month = tm.tm_mon + 1;
+ d->day = tm.tm_mday;
+ d->year = tm.tm_year + 1900;
+
+ g_return_if_fail (g_date_valid_dmy (d->day, d->month, d->year));
+
+ d->dmy = TRUE;
}
void