s/time_t/GTime/ and s/g_print/g_message/ include time.h.

Wed Dec  2 02:10:59 1998  Tim Janik  <timj@gtk.org>

        * gdate.c: s/time_t/GTime/ and s/g_print/g_message/
        include time.h.

        * glib.h: removed #include <time.h>, changed time_t paramter of
        g_date_set_time() to time_t, changed struct tm parameter of
        g_date_to_struct_tm to `gpointer struct_tm_p'. yes, this is not
        nice, but including time.h actually breaks a bunch of code.
This commit is contained in:
Tim Janik 1998-12-02 02:24:14 +00:00 committed by Tim Janik
parent a3e59c3ebf
commit 2886be294a
13 changed files with 523 additions and 419 deletions

View File

@ -1,3 +1,15 @@
Wed Dec 2 02:10:59 1998 Tim Janik <timj@gtk.org>
* gdate.c: s/time_t/GTime/ and s/g_print/g_message/
include time.h.
* glib.h: removed #include <time.h>, changed time_t paramter of
g_date_set_time() to time_t, changed struct tm parameter of
g_date_to_struct_tm to `gpointer struct_tm_p'. yes, this is not
nice, but including time.h actually breaks a bunch of code.
* incremented GLib version to 1.1.6.
1998-11-30 Havoc Pennington <hp@pobox.com> 1998-11-30 Havoc Pennington <hp@pobox.com>
* gdate.c: New file, implements calendrical calculations. * gdate.c: New file, implements calendrical calculations.

View File

@ -1,3 +1,15 @@
Wed Dec 2 02:10:59 1998 Tim Janik <timj@gtk.org>
* gdate.c: s/time_t/GTime/ and s/g_print/g_message/
include time.h.
* glib.h: removed #include <time.h>, changed time_t paramter of
g_date_set_time() to time_t, changed struct tm parameter of
g_date_to_struct_tm to `gpointer struct_tm_p'. yes, this is not
nice, but including time.h actually breaks a bunch of code.
* incremented GLib version to 1.1.6.
1998-11-30 Havoc Pennington <hp@pobox.com> 1998-11-30 Havoc Pennington <hp@pobox.com>
* gdate.c: New file, implements calendrical calculations. * gdate.c: New file, implements calendrical calculations.

View File

@ -1,3 +1,15 @@
Wed Dec 2 02:10:59 1998 Tim Janik <timj@gtk.org>
* gdate.c: s/time_t/GTime/ and s/g_print/g_message/
include time.h.
* glib.h: removed #include <time.h>, changed time_t paramter of
g_date_set_time() to time_t, changed struct tm parameter of
g_date_to_struct_tm to `gpointer struct_tm_p'. yes, this is not
nice, but including time.h actually breaks a bunch of code.
* incremented GLib version to 1.1.6.
1998-11-30 Havoc Pennington <hp@pobox.com> 1998-11-30 Havoc Pennington <hp@pobox.com>
* gdate.c: New file, implements calendrical calculations. * gdate.c: New file, implements calendrical calculations.

View File

@ -1,3 +1,15 @@
Wed Dec 2 02:10:59 1998 Tim Janik <timj@gtk.org>
* gdate.c: s/time_t/GTime/ and s/g_print/g_message/
include time.h.
* glib.h: removed #include <time.h>, changed time_t paramter of
g_date_set_time() to time_t, changed struct tm parameter of
g_date_to_struct_tm to `gpointer struct_tm_p'. yes, this is not
nice, but including time.h actually breaks a bunch of code.
* incremented GLib version to 1.1.6.
1998-11-30 Havoc Pennington <hp@pobox.com> 1998-11-30 Havoc Pennington <hp@pobox.com>
* gdate.c: New file, implements calendrical calculations. * gdate.c: New file, implements calendrical calculations.

View File

@ -1,3 +1,15 @@
Wed Dec 2 02:10:59 1998 Tim Janik <timj@gtk.org>
* gdate.c: s/time_t/GTime/ and s/g_print/g_message/
include time.h.
* glib.h: removed #include <time.h>, changed time_t paramter of
g_date_set_time() to time_t, changed struct tm parameter of
g_date_to_struct_tm to `gpointer struct_tm_p'. yes, this is not
nice, but including time.h actually breaks a bunch of code.
* incremented GLib version to 1.1.6.
1998-11-30 Havoc Pennington <hp@pobox.com> 1998-11-30 Havoc Pennington <hp@pobox.com>
* gdate.c: New file, implements calendrical calculations. * gdate.c: New file, implements calendrical calculations.

View File

@ -1,3 +1,15 @@
Wed Dec 2 02:10:59 1998 Tim Janik <timj@gtk.org>
* gdate.c: s/time_t/GTime/ and s/g_print/g_message/
include time.h.
* glib.h: removed #include <time.h>, changed time_t paramter of
g_date_set_time() to time_t, changed struct tm parameter of
g_date_to_struct_tm to `gpointer struct_tm_p'. yes, this is not
nice, but including time.h actually breaks a bunch of code.
* incremented GLib version to 1.1.6.
1998-11-30 Havoc Pennington <hp@pobox.com> 1998-11-30 Havoc Pennington <hp@pobox.com>
* gdate.c: New file, implements calendrical calculations. * gdate.c: New file, implements calendrical calculations.

View File

@ -1,3 +1,15 @@
Wed Dec 2 02:10:59 1998 Tim Janik <timj@gtk.org>
* gdate.c: s/time_t/GTime/ and s/g_print/g_message/
include time.h.
* glib.h: removed #include <time.h>, changed time_t paramter of
g_date_set_time() to time_t, changed struct tm parameter of
g_date_to_struct_tm to `gpointer struct_tm_p'. yes, this is not
nice, but including time.h actually breaks a bunch of code.
* incremented GLib version to 1.1.6.
1998-11-30 Havoc Pennington <hp@pobox.com> 1998-11-30 Havoc Pennington <hp@pobox.com>
* gdate.c: New file, implements calendrical calculations. * gdate.c: New file, implements calendrical calculations.

View File

@ -1,3 +1,15 @@
Wed Dec 2 02:10:59 1998 Tim Janik <timj@gtk.org>
* gdate.c: s/time_t/GTime/ and s/g_print/g_message/
include time.h.
* glib.h: removed #include <time.h>, changed time_t paramter of
g_date_set_time() to time_t, changed struct tm parameter of
g_date_to_struct_tm to `gpointer struct_tm_p'. yes, this is not
nice, but including time.h actually breaks a bunch of code.
* incremented GLib version to 1.1.6.
1998-11-30 Havoc Pennington <hp@pobox.com> 1998-11-30 Havoc Pennington <hp@pobox.com>
* gdate.c: New file, implements calendrical calculations. * gdate.c: New file, implements calendrical calculations.

View File

@ -18,7 +18,7 @@ cflags_set=${CFLAGS+set}
# #
GLIB_MAJOR_VERSION=1 GLIB_MAJOR_VERSION=1
GLIB_MINOR_VERSION=1 GLIB_MINOR_VERSION=1
GLIB_MICRO_VERSION=5 GLIB_MICRO_VERSION=6
GLIB_INTERFACE_AGE=0 GLIB_INTERFACE_AGE=0
GLIB_BINARY_AGE=0 GLIB_BINARY_AGE=0
GLIB_VERSION=$GLIB_MAJOR_VERSION.$GLIB_MINOR_VERSION.$GLIB_MICRO_VERSION GLIB_VERSION=$GLIB_MAJOR_VERSION.$GLIB_MINOR_VERSION.$GLIB_MICRO_VERSION

102
gdate.c
View File

@ -18,6 +18,7 @@
*/ */
#include "glib.h" #include "glib.h"
#include <time.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <stdlib.h> #include <stdlib.h>
@ -146,15 +147,15 @@ g_date_valid_julian (guint32 j)
gboolean gboolean
g_date_valid_mdy (GDateMonth m, g_date_valid_mdy (GDateMonth m,
GDateDay d, GDateDay d,
GDateYear y) GDateYear y)
{ {
return ( (m > G_DATE_BAD_MONTH) && return ( (m > G_DATE_BAD_MONTH) &&
(m < 13) && (m < 13) &&
(d > G_DATE_BAD_DAY) && (d > G_DATE_BAD_DAY) &&
(y > G_DATE_BAD_YEAR) && /* must check before using g_date_is_leap_year */ (y > G_DATE_BAD_YEAR) && /* must check before using g_date_is_leap_year */
(d <= (g_date_is_leap_year (y) ? (d <= (g_date_is_leap_year (y) ?
days_in_months[1][m] : days_in_months[0][m])) ); days_in_months[1][m] : days_in_months[0][m])) );
} }
@ -232,7 +233,7 @@ g_date_update_mdy (GDate *d)
if (!g_date_valid_mdy (m, day, y)) if (!g_date_valid_mdy (m, day, y))
{ {
g_warning ("\nOOPS julian: %u computed mdy: %u %u %u\n", g_warning ("\nOOPS julian: %u computed mdy: %u %u %u\n",
d->julian_days, m, day, y); d->julian_days, m, day, y);
} }
#endif #endif
@ -603,16 +604,16 @@ g_date_prepare_to_parse (const gchar *str, GDateParseTokens *pt)
} }
#ifdef G_ENABLE_DEBUG #ifdef G_ENABLE_DEBUG
g_print ("\n**GDate prepared a new set of locale-specific parse rules.\n"); g_message ("**GDate prepared a new set of locale-specific parse rules.");
i = 1; i = 1;
while (i < 13) while (i < 13)
{ {
g_print (" %s %s\n", long_month_names[i], short_month_names[i]); g_message (" %s %s", long_month_names[i], short_month_names[i]);
++i; ++i;
} }
if (using_twodigit_years) if (using_twodigit_years)
{ {
g_print ("**Using twodigit years with cutoff year: %u\n", twodigit_start_year); g_message ("**Using twodigit years with cutoff year: %u", twodigit_start_year);
} }
{ {
gchar *strings[3]; gchar *strings[3];
@ -636,8 +637,8 @@ g_date_prepare_to_parse (const gchar *str, GDateParseTokens *pt)
} }
++i; ++i;
} }
g_print ("**Order: %s, %s, %s\n", strings[0], strings[1], strings[2]); g_message ("**Order: %s, %s, %s", strings[0], strings[1], strings[2]);
g_print ("**Sample date in this locale: `%s'\n\n", buf); g_message ("**Sample date in this locale: `%s'", buf);
} }
#endif #endif
} }
@ -660,8 +661,8 @@ g_date_set_parse (GDate *d,
g_date_prepare_to_parse (str, &pt); g_date_prepare_to_parse (str, &pt);
#ifdef G_ENABLE_DEBUG #ifdef G_ENABLE_DEBUG
g_print ("Found %d ints, `%d' `%d' `%d' and written out month %d\n", 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); pt.num_ints, pt.n[0], pt.n[1], pt.n[2], pt.month);
#endif #endif
@ -679,44 +680,44 @@ g_date_set_parse (GDate *d,
switch (mdy_order[j]) switch (mdy_order[j])
{ {
case G_DATE_MONTH: case G_DATE_MONTH:
{ {
if (pt.num_ints == 2 && pt.month != G_DATE_BAD_MONTH) if (pt.num_ints == 2 && pt.month != G_DATE_BAD_MONTH)
{ {
m = pt.month; m = pt.month;
++j; /* skip months, but don't skip this number */ ++j; /* skip months, but don't skip this number */
continue; continue;
} }
else else
m = pt.n[i]; m = pt.n[i];
} }
break; break;
case G_DATE_DAY: case G_DATE_DAY:
{ {
if (pt.num_ints == 2 && pt.month == G_DATE_BAD_MONTH) if (pt.num_ints == 2 && pt.month == G_DATE_BAD_MONTH)
{ {
day = 1; day = 1;
++j; /* skip days, since we may have month/year */ ++j; /* skip days, since we may have month/year */
continue; continue;
} }
day = pt.n[i]; day = pt.n[i];
} }
break; break;
case G_DATE_YEAR: case G_DATE_YEAR:
{ {
y = pt.n[i]; y = pt.n[i];
if (using_twodigit_years && y < 100) if (using_twodigit_years && y < 100)
{ {
guint two = twodigit_start_year % 100; guint two = twodigit_start_year % 100;
guint century = (twodigit_start_year / 100) * 100; guint century = (twodigit_start_year / 100) * 100;
if (y < two) if (y < two)
century += 100; century += 100;
y += century; y += century;
} }
} }
break; break;
default: default:
break; break;
} }
@ -779,13 +780,15 @@ g_date_set_parse (GDate *d,
} }
#ifdef G_ENABLE_DEBUG #ifdef G_ENABLE_DEBUG
else else
g_print ("Rejected MDY %u %u %u\n", m, day, y); g_message ("Rejected MDY %u %u %u", m, day, y);
#endif #endif
} }
void void
g_date_set_time (GDate *d, time_t t) g_date_set_time (GDate *d,
GTime time)
{ {
time_t t = time;
struct tm *tm; struct tm *tm;
g_return_if_fail (d != NULL); g_return_if_fail (d != NULL);
@ -1209,13 +1212,16 @@ g_date_compare (GDate *lhs,
void void
g_date_to_struct_tm (GDate *d, g_date_to_struct_tm (GDate *d,
struct tm *tm) gpointer struct_tm_p)
{ {
GDateWeekday day; GDateWeekday day;
struct tm *tm;
g_return_if_fail (d != NULL); g_return_if_fail (d != NULL);
g_return_if_fail (g_date_valid (d)); g_return_if_fail (g_date_valid (d));
g_return_if_fail (tm != NULL); g_return_if_fail (struct_tm_p != NULL);
tm = struct_tm_p;
if (!d->mdy) if (!d->mdy)
{ {

6
glib.h
View File

@ -2039,8 +2039,6 @@ void g_completion_free (GCompletion* cmp);
* Pennington <hp@pobox.com> * Pennington <hp@pobox.com>
*/ */
#include <time.h>
/* this enum is used to specify order of appearance in parsed date /* this enum is used to specify order of appearance in parsed date
* strings * strings
*/ */
@ -2172,7 +2170,7 @@ void g_date_set_parse (GDate *d,
const gchar *str); const gchar *str);
void g_date_set_time (GDate *d, void g_date_set_time (GDate *d,
time_t t); GTime time);
void g_date_set_month (GDate *d, void g_date_set_month (GDate *d,
GDateMonth m); GDateMonth m);
@ -2222,7 +2220,7 @@ gint g_date_compare (GDate *lhs,
void g_date_to_struct_tm (GDate *d, void g_date_to_struct_tm (GDate *d,
struct tm *tm); gpointer struct_tm_p);
/* Just like strftime() except you can only use date-related formats. /* Just like strftime() except you can only use date-related formats.
* Using a time format is undefined. * Using a time format is undefined.

View File

@ -18,6 +18,7 @@
*/ */
#include "glib.h" #include "glib.h"
#include <time.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <stdlib.h> #include <stdlib.h>
@ -146,15 +147,15 @@ g_date_valid_julian (guint32 j)
gboolean gboolean
g_date_valid_mdy (GDateMonth m, g_date_valid_mdy (GDateMonth m,
GDateDay d, GDateDay d,
GDateYear y) GDateYear y)
{ {
return ( (m > G_DATE_BAD_MONTH) && return ( (m > G_DATE_BAD_MONTH) &&
(m < 13) && (m < 13) &&
(d > G_DATE_BAD_DAY) && (d > G_DATE_BAD_DAY) &&
(y > G_DATE_BAD_YEAR) && /* must check before using g_date_is_leap_year */ (y > G_DATE_BAD_YEAR) && /* must check before using g_date_is_leap_year */
(d <= (g_date_is_leap_year (y) ? (d <= (g_date_is_leap_year (y) ?
days_in_months[1][m] : days_in_months[0][m])) ); days_in_months[1][m] : days_in_months[0][m])) );
} }
@ -232,7 +233,7 @@ g_date_update_mdy (GDate *d)
if (!g_date_valid_mdy (m, day, y)) if (!g_date_valid_mdy (m, day, y))
{ {
g_warning ("\nOOPS julian: %u computed mdy: %u %u %u\n", g_warning ("\nOOPS julian: %u computed mdy: %u %u %u\n",
d->julian_days, m, day, y); d->julian_days, m, day, y);
} }
#endif #endif
@ -603,16 +604,16 @@ g_date_prepare_to_parse (const gchar *str, GDateParseTokens *pt)
} }
#ifdef G_ENABLE_DEBUG #ifdef G_ENABLE_DEBUG
g_print ("\n**GDate prepared a new set of locale-specific parse rules.\n"); g_message ("**GDate prepared a new set of locale-specific parse rules.");
i = 1; i = 1;
while (i < 13) while (i < 13)
{ {
g_print (" %s %s\n", long_month_names[i], short_month_names[i]); g_message (" %s %s", long_month_names[i], short_month_names[i]);
++i; ++i;
} }
if (using_twodigit_years) if (using_twodigit_years)
{ {
g_print ("**Using twodigit years with cutoff year: %u\n", twodigit_start_year); g_message ("**Using twodigit years with cutoff year: %u", twodigit_start_year);
} }
{ {
gchar *strings[3]; gchar *strings[3];
@ -636,8 +637,8 @@ g_date_prepare_to_parse (const gchar *str, GDateParseTokens *pt)
} }
++i; ++i;
} }
g_print ("**Order: %s, %s, %s\n", strings[0], strings[1], strings[2]); g_message ("**Order: %s, %s, %s", strings[0], strings[1], strings[2]);
g_print ("**Sample date in this locale: `%s'\n\n", buf); g_message ("**Sample date in this locale: `%s'", buf);
} }
#endif #endif
} }
@ -660,8 +661,8 @@ g_date_set_parse (GDate *d,
g_date_prepare_to_parse (str, &pt); g_date_prepare_to_parse (str, &pt);
#ifdef G_ENABLE_DEBUG #ifdef G_ENABLE_DEBUG
g_print ("Found %d ints, `%d' `%d' `%d' and written out month %d\n", 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); pt.num_ints, pt.n[0], pt.n[1], pt.n[2], pt.month);
#endif #endif
@ -679,44 +680,44 @@ g_date_set_parse (GDate *d,
switch (mdy_order[j]) switch (mdy_order[j])
{ {
case G_DATE_MONTH: case G_DATE_MONTH:
{ {
if (pt.num_ints == 2 && pt.month != G_DATE_BAD_MONTH) if (pt.num_ints == 2 && pt.month != G_DATE_BAD_MONTH)
{ {
m = pt.month; m = pt.month;
++j; /* skip months, but don't skip this number */ ++j; /* skip months, but don't skip this number */
continue; continue;
} }
else else
m = pt.n[i]; m = pt.n[i];
} }
break; break;
case G_DATE_DAY: case G_DATE_DAY:
{ {
if (pt.num_ints == 2 && pt.month == G_DATE_BAD_MONTH) if (pt.num_ints == 2 && pt.month == G_DATE_BAD_MONTH)
{ {
day = 1; day = 1;
++j; /* skip days, since we may have month/year */ ++j; /* skip days, since we may have month/year */
continue; continue;
} }
day = pt.n[i]; day = pt.n[i];
} }
break; break;
case G_DATE_YEAR: case G_DATE_YEAR:
{ {
y = pt.n[i]; y = pt.n[i];
if (using_twodigit_years && y < 100) if (using_twodigit_years && y < 100)
{ {
guint two = twodigit_start_year % 100; guint two = twodigit_start_year % 100;
guint century = (twodigit_start_year / 100) * 100; guint century = (twodigit_start_year / 100) * 100;
if (y < two) if (y < two)
century += 100; century += 100;
y += century; y += century;
} }
} }
break; break;
default: default:
break; break;
} }
@ -779,13 +780,15 @@ g_date_set_parse (GDate *d,
} }
#ifdef G_ENABLE_DEBUG #ifdef G_ENABLE_DEBUG
else else
g_print ("Rejected MDY %u %u %u\n", m, day, y); g_message ("Rejected MDY %u %u %u", m, day, y);
#endif #endif
} }
void void
g_date_set_time (GDate *d, time_t t) g_date_set_time (GDate *d,
GTime time)
{ {
time_t t = time;
struct tm *tm; struct tm *tm;
g_return_if_fail (d != NULL); g_return_if_fail (d != NULL);
@ -1209,13 +1212,16 @@ g_date_compare (GDate *lhs,
void void
g_date_to_struct_tm (GDate *d, g_date_to_struct_tm (GDate *d,
struct tm *tm) gpointer struct_tm_p)
{ {
GDateWeekday day; GDateWeekday day;
struct tm *tm;
g_return_if_fail (d != NULL); g_return_if_fail (d != NULL);
g_return_if_fail (g_date_valid (d)); g_return_if_fail (g_date_valid (d));
g_return_if_fail (tm != NULL); g_return_if_fail (struct_tm_p != NULL);
tm = struct_tm_p;
if (!d->mdy) if (!d->mdy)
{ {

View File

@ -2039,8 +2039,6 @@ void g_completion_free (GCompletion* cmp);
* Pennington <hp@pobox.com> * Pennington <hp@pobox.com>
*/ */
#include <time.h>
/* this enum is used to specify order of appearance in parsed date /* this enum is used to specify order of appearance in parsed date
* strings * strings
*/ */
@ -2172,7 +2170,7 @@ void g_date_set_parse (GDate *d,
const gchar *str); const gchar *str);
void g_date_set_time (GDate *d, void g_date_set_time (GDate *d,
time_t t); GTime time);
void g_date_set_month (GDate *d, void g_date_set_month (GDate *d,
GDateMonth m); GDateMonth m);
@ -2222,7 +2220,7 @@ gint g_date_compare (GDate *lhs,
void g_date_to_struct_tm (GDate *d, void g_date_to_struct_tm (GDate *d,
struct tm *tm); gpointer struct_tm_p);
/* Just like strftime() except you can only use date-related formats. /* Just like strftime() except you can only use date-related formats.
* Using a time format is undefined. * Using a time format is undefined.