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>
* 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>
* 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>
* 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>
* 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>
* 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>
* 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>
* 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>
* gdate.c: New file, implements calendrical calculations.

View File

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

102
gdate.c
View File

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

6
glib.h
View File

@ -2039,8 +2039,6 @@ void g_completion_free (GCompletion* cmp);
* Pennington <hp@pobox.com>
*/
#include <time.h>
/* this enum is used to specify order of appearance in parsed date
* strings
*/
@ -2172,7 +2170,7 @@ void g_date_set_parse (GDate *d,
const gchar *str);
void g_date_set_time (GDate *d,
time_t t);
GTime time);
void g_date_set_month (GDate *d,
GDateMonth m);
@ -2222,7 +2220,7 @@ gint g_date_compare (GDate *lhs,
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.
* Using a time format is undefined.

View File

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

View File

@ -2039,8 +2039,6 @@ void g_completion_free (GCompletion* cmp);
* Pennington <hp@pobox.com>
*/
#include <time.h>
/* this enum is used to specify order of appearance in parsed date
* strings
*/
@ -2172,7 +2170,7 @@ void g_date_set_parse (GDate *d,
const gchar *str);
void g_date_set_time (GDate *d,
time_t t);
GTime time);
void g_date_set_month (GDate *d,
GDateMonth m);
@ -2222,7 +2220,7 @@ gint g_date_compare (GDate *lhs,
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.
* Using a time format is undefined.