Commit 855e230f authored by Ali Abdin's avatar Ali Abdin Committed by Ali Abdin

New gcompat.h header file as recommended by Havoc.

2000-12-24  Ali Abdin  <aliabdin@aucegypt.edu>

        * Makefile.am, gcompat.h, glib.h: New gcompat.h header file
          as recommended by Havoc.

        * gdate.c, gdate.h, testgdate.c,
          docs/reference/glib/glib-sections.txt,
          docs/reference/glib/tmpl/date.sgml, tests/date-test.c: Rename some
          of the gdate functions to use the '_get' in their name. Patch
          reviewed by Havoc.
parent 57a7a2b0
2000-12-24 Ali Abdin <aliabdin@aucegypt.edu>
* Makefile.am, gcompat.h, glib.h: New gcompat.h header file
as recommended by Havoc.
* gdate.c, gdate.h, testgdate.c,
docs/reference/glib/glib-sections.txt,
docs/reference/glib/tmpl/date.sgml, tests/date-test.c: Rename some
of the gdate functions to use the '_get' in their name. Patch
reviewed by Havoc.
2000-12-22 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Determine the suffix of the shared librarries for
......
2000-12-24 Ali Abdin <aliabdin@aucegypt.edu>
* Makefile.am, gcompat.h, glib.h: New gcompat.h header file
as recommended by Havoc.
* gdate.c, gdate.h, testgdate.c,
docs/reference/glib/glib-sections.txt,
docs/reference/glib/tmpl/date.sgml, tests/date-test.c: Rename some
of the gdate functions to use the '_get' in their name. Patch
reviewed by Havoc.
2000-12-22 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Determine the suffix of the shared librarries for
......
2000-12-24 Ali Abdin <aliabdin@aucegypt.edu>
* Makefile.am, gcompat.h, glib.h: New gcompat.h header file
as recommended by Havoc.
* gdate.c, gdate.h, testgdate.c,
docs/reference/glib/glib-sections.txt,
docs/reference/glib/tmpl/date.sgml, tests/date-test.c: Rename some
of the gdate functions to use the '_get' in their name. Patch
reviewed by Havoc.
2000-12-22 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Determine the suffix of the shared librarries for
......
2000-12-24 Ali Abdin <aliabdin@aucegypt.edu>
* Makefile.am, gcompat.h, glib.h: New gcompat.h header file
as recommended by Havoc.
* gdate.c, gdate.h, testgdate.c,
docs/reference/glib/glib-sections.txt,
docs/reference/glib/tmpl/date.sgml, tests/date-test.c: Rename some
of the gdate functions to use the '_get' in their name. Patch
reviewed by Havoc.
2000-12-22 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Determine the suffix of the shared librarries for
......
2000-12-24 Ali Abdin <aliabdin@aucegypt.edu>
* Makefile.am, gcompat.h, glib.h: New gcompat.h header file
as recommended by Havoc.
* gdate.c, gdate.h, testgdate.c,
docs/reference/glib/glib-sections.txt,
docs/reference/glib/tmpl/date.sgml, tests/date-test.c: Rename some
of the gdate functions to use the '_get' in their name. Patch
reviewed by Havoc.
2000-12-22 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Determine the suffix of the shared librarries for
......
2000-12-24 Ali Abdin <aliabdin@aucegypt.edu>
* Makefile.am, gcompat.h, glib.h: New gcompat.h header file
as recommended by Havoc.
* gdate.c, gdate.h, testgdate.c,
docs/reference/glib/glib-sections.txt,
docs/reference/glib/tmpl/date.sgml, tests/date-test.c: Rename some
of the gdate functions to use the '_get' in their name. Patch
reviewed by Havoc.
2000-12-22 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Determine the suffix of the shared librarries for
......
2000-12-24 Ali Abdin <aliabdin@aucegypt.edu>
* Makefile.am, gcompat.h, glib.h: New gcompat.h header file
as recommended by Havoc.
* gdate.c, gdate.h, testgdate.c,
docs/reference/glib/glib-sections.txt,
docs/reference/glib/tmpl/date.sgml, tests/date-test.c: Rename some
of the gdate functions to use the '_get' in their name. Patch
reviewed by Havoc.
2000-12-22 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Determine the suffix of the shared librarries for
......
2000-12-24 Ali Abdin <aliabdin@aucegypt.edu>
* Makefile.am, gcompat.h, glib.h: New gcompat.h header file
as recommended by Havoc.
* gdate.c, gdate.h, testgdate.c,
docs/reference/glib/glib-sections.txt,
docs/reference/glib/tmpl/date.sgml, tests/date-test.c: Rename some
of the gdate functions to use the '_get' in their name. Patch
reviewed by Havoc.
2000-12-22 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Determine the suffix of the shared librarries for
......
......@@ -8,7 +8,8 @@ bin_SCRIPTS=glib-config-2.0
BUILT_SOURCES=glib-config-2.0
glib-config-2.0: glib-config-2.0.in
INCLUDES = -DG_LOG_DOMAIN=g_log_domain_glib @GLIB_DEBUG_FLAGS@
INCLUDES = -DG_LOG_DOMAIN=g_log_domain_glib @GLIB_DEBUG_FLAGS@ \
-DG_DISBALE_COMPAT_H
EXTRA_DIST = \
ChangeLog.pre-1-2 \
......@@ -101,6 +102,7 @@ glibinclude_HEADERS = \
gasyncqueue.h \
gbacktrace.h \
gcache.h \
gcompat.h \
gcompletion.h \
gconvert.h \
gdataset.h \
......
......@@ -879,22 +879,22 @@ g_date_subtract_years
g_date_compare
<SUBSECTION>
g_date_day
g_date_month
g_date_year
g_date_julian
g_date_weekday
g_date_day_of_year
g_date_get_day
g_date_get_month
g_date_get_year
g_date_get_julian
g_date_get_weekday
g_date_get_day_of_year
<SUBSECTION>
g_date_days_in_month
g_date_get_days_in_month
g_date_is_first_of_month
g_date_is_last_of_month
g_date_is_leap_year
g_date_monday_week_of_year
g_date_monday_weeks_in_year
g_date_sunday_week_of_year
g_date_sunday_weeks_in_year
g_date_get_monday_week_of_year
g_date_get_monday_weeks_in_year
g_date_get_sunday_week_of_year
g_date_get_sunday_weeks_in_year
<SUBSECTION>
g_date_strftime
......
......@@ -422,7 +422,7 @@ dates must be valid.
greater than zero if @lhs is greater than @rhs
<!-- ##### FUNCTION g_date_day ##### -->
<!-- ##### FUNCTION g_date_get_day ##### -->
<para>
Return the day of the month; the #GDate must be valid.
</para>
......@@ -431,7 +431,7 @@ Return the day of the month; the #GDate must be valid.
@Returns: Day of the month
<!-- ##### FUNCTION g_date_month ##### -->
<!-- ##### FUNCTION g_date_get_month ##### -->
<para>
Accessor for the month of the year. Date must be valid.
</para>
......@@ -440,7 +440,7 @@ Accessor for the month of the year. Date must be valid.
@Returns: A #GDateMonth
<!-- ##### FUNCTION g_date_year ##### -->
<!-- ##### FUNCTION g_date_get_year ##### -->
<para>
Accessor; returns the year of a #GDate. The date must be valid.
</para>
......@@ -449,7 +449,7 @@ Accessor; returns the year of a #GDate. The date must be valid.
@Returns: Year in which the date falls
<!-- ##### FUNCTION g_date_julian ##### -->
<!-- ##### FUNCTION g_date_get_julian ##### -->
<para>
Accessor, returns the Julian day or "serial number" of the #GDate. The
Julian day is simply the number of days since January 1, Year 1; i.e.,
......@@ -461,7 +461,7 @@ etc. Date must be valid.
@Returns: Julian day
<!-- ##### FUNCTION g_date_weekday ##### -->
<!-- ##### FUNCTION g_date_get_weekday ##### -->
<para>
Returns the day of the week for a #GDate. The date must be valid.
</para>
......@@ -470,7 +470,7 @@ Returns the day of the week for a #GDate. The date must be valid.
@Returns: Day of the week as a #GDateWeekday
<!-- ##### FUNCTION g_date_day_of_year ##### -->
<!-- ##### FUNCTION g_date_get_day_of_year ##### -->
<para>
Return the day of the year, where Jan 1 is the first day of the
year. Date must be valid.
......@@ -480,7 +480,7 @@ year. Date must be valid.
@Returns: Day of the year
<!-- ##### FUNCTION g_date_days_in_month ##### -->
<!-- ##### FUNCTION g_date_get_days_in_month ##### -->
<para>
Return the number of days in a month, taking leap years into account.
</para>
......@@ -517,7 +517,7 @@ Returns TRUE if the year is a leap year
@Returns: Boolean, if the year is a leap year
<!-- ##### FUNCTION g_date_monday_week_of_year ##### -->
<!-- ##### FUNCTION g_date_get_monday_week_of_year ##### -->
<para>
Return the week of the year, where weeks are understood to start on
Monday. If the date is before the first Monday of the year, return
......@@ -528,7 +528,7 @@ Monday. If the date is before the first Monday of the year, return
@Returns: Week of the year
<!-- ##### FUNCTION g_date_monday_weeks_in_year ##### -->
<!-- ##### FUNCTION g_date_get_monday_weeks_in_year ##### -->
<para>
Return the number of weeks in the year, where weeks are taken to start
on Monday. Will be 52 or 53. Date must be valid. (Years always have 52
......@@ -542,7 +542,7 @@ to be a Monday.)
@Returns: Number of Mondays in the year
<!-- ##### FUNCTION g_date_sunday_week_of_year ##### -->
<!-- ##### FUNCTION g_date_get_sunday_week_of_year ##### -->
<para>
Week of the year during which this date falls, if weeks are understood
to being on Sunday. Date must be valid. Can return 0 if the day is
......@@ -553,7 +553,7 @@ before the first Sunday of the year.
@Returns: Week number
<!-- ##### FUNCTION g_date_sunday_weeks_in_year ##### -->
<!-- ##### FUNCTION g_date_get_sunday_weeks_in_year ##### -->
<para>
Return the number of weeks in the year, where weeks are taken to start
on Sunday. Will be 52 or 53. Date must be valid. (Years always have 52
......
/* GLIB - Library of useful routines for C programming
*
* Copyright (C) 2000 Ali Abdin <aliabdin@aucegypt.edu>
*
* 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-1307, USA.
*/
#ifndef __G_COMPAT_H__
#define __G_COMPAT_H__
#include <gmacros.h>
G_BEGIN_DECLS
#ifndef G_DISABLE_COMPAT_H
#define g_date_weekday g_date_get_weekday
#define g_date_month g_date_get_month
#define g_date_year g_date_get_year
#define g_date_day g_date_get_day
#define g_date_julian g_date_get_julian
#define g_date_day_of_year g_date_get_day_of_year
#define g_date_monday_week_of_year g_date_get_monday_week_of_year
#define g_date_sunday_week_of_year g_date_get_sunday_week_of_year
#define g_date_days_in_month g_date_get_days_in_month
#define g_date_monday_weeks_in_year g_date_get_monday_weeks_in_year
#define g_date_sunday_weeks_in_year g_date_get_sunday_weeks_in_year
#endif /* G_DISABLE_COMPAT_H */
G_END_DECLS
#endif /* __G_COMPAT_H__ */
......@@ -249,7 +249,7 @@ g_date_update_dmy (GDate *d)
}
GDateWeekday
g_date_weekday (GDate *d)
g_date_get_weekday (GDate *d)
{
g_return_val_if_fail (d != NULL, G_DATE_BAD_WEEKDAY);
g_return_val_if_fail (g_date_valid (d), G_DATE_BAD_WEEKDAY);
......@@ -264,7 +264,7 @@ g_date_weekday (GDate *d)
}
GDateMonth
g_date_month (GDate *d)
g_date_get_month (GDate *d)
{
g_return_val_if_fail (d != NULL, G_DATE_BAD_MONTH);
g_return_val_if_fail (g_date_valid (d), G_DATE_BAD_MONTH);
......@@ -279,7 +279,7 @@ g_date_month (GDate *d)
}
GDateYear
g_date_year (GDate *d)
g_date_get_year (GDate *d)
{
g_return_val_if_fail (d != NULL, G_DATE_BAD_YEAR);
g_return_val_if_fail (g_date_valid (d), G_DATE_BAD_YEAR);
......@@ -294,7 +294,7 @@ g_date_year (GDate *d)
}
GDateDay
g_date_day (GDate *d)
g_date_get_day (GDate *d)
{
g_return_val_if_fail (d != NULL, G_DATE_BAD_DAY);
g_return_val_if_fail (g_date_valid (d), G_DATE_BAD_DAY);
......@@ -309,7 +309,7 @@ g_date_day (GDate *d)
}
guint32
g_date_julian (GDate *d)
g_date_get_julian (GDate *d)
{
g_return_val_if_fail (d != NULL, G_DATE_BAD_JULIAN);
g_return_val_if_fail (g_date_valid (d), G_DATE_BAD_JULIAN);
......@@ -324,7 +324,7 @@ g_date_julian (GDate *d)
}
guint
g_date_day_of_year (GDate *d)
g_date_get_day_of_year (GDate *d)
{
gint index;
......@@ -343,7 +343,7 @@ g_date_day_of_year (GDate *d)
}
guint
g_date_monday_week_of_year (GDate *d)
g_date_get_monday_week_of_year (GDate *d)
{
GDateWeekday wd;
guint day;
......@@ -362,14 +362,14 @@ g_date_monday_week_of_year (GDate *d)
g_date_set_dmy (&first, 1, 1, d->year);
wd = g_date_weekday (&first) - 1; /* make Monday day 0 */
day = g_date_day_of_year (d) - 1;
wd = g_date_get_weekday (&first) - 1; /* make Monday day 0 */
day = g_date_get_day_of_year (d) - 1;
return ((day + wd)/7U + (wd == 0 ? 1 : 0));
}
guint
g_date_sunday_week_of_year (GDate *d)
g_date_get_sunday_week_of_year (GDate *d)
{
GDateWeekday wd;
guint day;
......@@ -388,9 +388,9 @@ g_date_sunday_week_of_year (GDate *d)
g_date_set_dmy (&first, 1, 1, d->year);
wd = g_date_weekday (&first);
wd = g_date_get_weekday (&first);
if (wd == 7) wd = 0; /* make Sunday day 0 */
day = g_date_day_of_year (d) - 1;
day = g_date_get_day_of_year (d) - 1;
return ((day + wd)/7U + (wd == 0 ? 1 : 0));
}
......@@ -1119,8 +1119,8 @@ g_date_is_leap_year (GDateYear year)
}
guint8
g_date_days_in_month (GDateMonth month,
GDateYear year)
g_date_get_days_in_month (GDateMonth month,
GDateYear year)
{
gint index;
......@@ -1133,7 +1133,7 @@ g_date_days_in_month (GDateMonth month,
}
guint8
g_date_monday_weeks_in_year (GDateYear year)
g_date_get_monday_weeks_in_year (GDateYear year)
{
GDate d;
......@@ -1141,21 +1141,21 @@ g_date_monday_weeks_in_year (GDateYear year)
g_date_clear (&d, 1);
g_date_set_dmy (&d, 1, 1, year);
if (g_date_weekday (&d) == G_DATE_MONDAY) return 53;
if (g_date_get_weekday (&d) == G_DATE_MONDAY) return 53;
g_date_set_dmy (&d, 31, 12, year);
if (g_date_weekday (&d) == G_DATE_MONDAY) return 53;
if (g_date_get_weekday (&d) == G_DATE_MONDAY) return 53;
if (g_date_is_leap_year (year))
{
g_date_set_dmy (&d, 2, 1, year);
if (g_date_weekday (&d) == G_DATE_MONDAY) return 53;
if (g_date_get_weekday (&d) == G_DATE_MONDAY) return 53;
g_date_set_dmy (&d, 30, 12, year);
if (g_date_weekday (&d) == G_DATE_MONDAY) return 53;
if (g_date_get_weekday (&d) == G_DATE_MONDAY) return 53;
}
return 52;
}
guint8
g_date_sunday_weeks_in_year (GDateYear year)
g_date_get_sunday_weeks_in_year (GDateYear year)
{
GDate d;
......@@ -1163,15 +1163,15 @@ g_date_sunday_weeks_in_year (GDateYear year)
g_date_clear (&d, 1);
g_date_set_dmy (&d, 1, 1, year);
if (g_date_weekday (&d) == G_DATE_SUNDAY) return 53;
if (g_date_get_weekday (&d) == G_DATE_SUNDAY) return 53;
g_date_set_dmy (&d, 31, 12, year);
if (g_date_weekday (&d) == G_DATE_SUNDAY) return 53;
if (g_date_get_weekday (&d) == G_DATE_SUNDAY) return 53;
if (g_date_is_leap_year (year))
{
g_date_set_dmy (&d, 2, 1, year);
if (g_date_weekday (&d) == G_DATE_SUNDAY) return 53;
if (g_date_get_weekday (&d) == G_DATE_SUNDAY) return 53;
g_date_set_dmy (&d, 30, 12, year);
if (g_date_weekday (&d) == G_DATE_SUNDAY) return 53;
if (g_date_get_weekday (&d) == G_DATE_SUNDAY) return 53;
}
return 52;
}
......@@ -1257,12 +1257,12 @@ g_date_to_struct_tm (GDate *d,
tm->tm_mon = d->month - 1; /* 0-11 goes in tm */
tm->tm_year = ((int)d->year) - 1900; /* X/Open says tm_year can be negative */
day = g_date_weekday (d);
day = g_date_get_weekday (d);
if (day == 7) day = 0; /* struct tm wants days since Sunday, so Sunday is 0 */
tm->tm_wday = (int)day;
tm->tm_yday = g_date_day_of_year (d) - 1; /* 0 to 365 */
tm->tm_yday = g_date_get_day_of_year (d) - 1; /* 0 to 365 */
tm->tm_isdst = -1; /* -1 means "information not available" */
}
......
......@@ -136,20 +136,20 @@ gboolean g_date_valid_dmy (GDateDay day,
GDateMonth month,
GDateYear year) G_GNUC_CONST;
GDateWeekday g_date_weekday (GDate *date);
GDateMonth g_date_month (GDate *date);
GDateYear g_date_year (GDate *date);
GDateDay g_date_day (GDate *date);
guint32 g_date_julian (GDate *date);
guint g_date_day_of_year (GDate *date);
GDateWeekday g_date_get_weekday (GDate *date);
GDateMonth g_date_get_month (GDate *date);
GDateYear g_date_get_year (GDate *date);
GDateDay g_date_get_day (GDate *date);
guint32 g_date_get_julian (GDate *date);
guint g_date_get_day_of_year (GDate *date);
/* First monday/sunday is the start of week 1; if we haven't reached
* that day, return 0. These are not ISO weeks of the year; that
* routine needs to be added.
* these functions return the number of weeks, starting on the
* corrsponding day
*/
guint g_date_monday_week_of_year (GDate *date);
guint g_date_sunday_week_of_year (GDate *date);
guint g_date_get_monday_week_of_year (GDate *date);
guint g_date_get_sunday_week_of_year (GDate *date);
/* If you create a static date struct you need to clear it to get it
* in a sane state before use. You can clear a whole array at
......@@ -199,10 +199,10 @@ void g_date_add_years (GDate *date,
void g_date_subtract_years (GDate *date,
guint n_years);
gboolean g_date_is_leap_year (GDateYear year) G_GNUC_CONST;
guint8 g_date_days_in_month (GDateMonth month,
guint8 g_date_get_days_in_month (GDateMonth month,
GDateYear year) G_GNUC_CONST;
guint8 g_date_monday_weeks_in_year (GDateYear year) G_GNUC_CONST;
guint8 g_date_sunday_weeks_in_year (GDateYear year) G_GNUC_CONST;
guint8 g_date_get_monday_weeks_in_year (GDateYear year) G_GNUC_CONST;
guint8 g_date_get_sunday_weeks_in_year (GDateYear year) G_GNUC_CONST;
/* qsort-friendly (with a cast...) */
gint g_date_compare (GDate *lhs,
......
......@@ -32,6 +32,7 @@
#include <gasyncqueue.h>
#include <gbacktrace.h>
#include <gcache.h>
#include <gcompat.h>
#include <gcompletion.h>
#include <gconvert.h>
#include <gdataset.h>
......
......@@ -8,7 +8,8 @@ bin_SCRIPTS=glib-config-2.0
BUILT_SOURCES=glib-config-2.0
glib-config-2.0: glib-config-2.0.in
INCLUDES = -DG_LOG_DOMAIN=g_log_domain_glib @GLIB_DEBUG_FLAGS@
INCLUDES = -DG_LOG_DOMAIN=g_log_domain_glib @GLIB_DEBUG_FLAGS@ \
-DG_DISBALE_COMPAT_H
EXTRA_DIST = \
ChangeLog.pre-1-2 \
......@@ -101,6 +102,7 @@ glibinclude_HEADERS = \
gasyncqueue.h \
gbacktrace.h \
gcache.h \
gcompat.h \
gcompletion.h \
gconvert.h \
gdataset.h \
......
......@@ -249,7 +249,7 @@ g_date_update_dmy (GDate *d)
}
GDateWeekday
g_date_weekday (GDate *d)
g_date_get_weekday (GDate *d)
{
g_return_val_if_fail (d != NULL, G_DATE_BAD_WEEKDAY);
g_return_val_if_fail (g_date_valid (d), G_DATE_BAD_WEEKDAY);
......@@ -264,7 +264,7 @@ g_date_weekday (GDate *d)
}
GDateMonth
g_date_month (GDate *d)
g_date_get_month (GDate *d)
{
g_return_val_if_fail (d != NULL, G_DATE_BAD_MONTH);
g_return_val_if_fail (g_date_valid (d), G_DATE_BAD_MONTH);
......@@ -279,7 +279,7 @@ g_date_month (GDate *d)
}
GDateYear
g_date_year (GDate *d)
g_date_get_year (GDate *d)
{
g_return_val_if_fail (d != NULL, G_DATE_BAD_YEAR);
g_return_val_if_fail (g_date_valid (d), G_DATE_BAD_YEAR);
......@@ -294,7 +294,7 @@ g_date_year (GDate *d)
}
GDateDay
g_date_day (GDate *d)
g_date_get_day (GDate *d)
{
g_return_val_if_fail (d != NULL, G_DATE_BAD_DAY);
g_return_val_if_fail (g_date_valid (d), G_DATE_BAD_DAY);
......@@ -309,7 +309,7 @@ g_date_day (GDate *d)
}
guint32
g_date_julian (GDate *d)
g_date_get_julian (GDate *d)
{
g_return_val_if_fail (d != NULL, G_DATE_BAD_JULIAN);
g_return_val_if_fail (g_date_valid (d), G_DATE_BAD_JULIAN);
......@@ -324,7 +324,7 @@ g_date_julian (GDate *d)
}
guint
g_date_day_of_year (GDate *d)
g_date_get_day_of_year (GDate *d)
{
gint index;
......@@ -343,7 +343,7 @@ g_date_day_of_year (GDate *d)
}
guint
g_date_monday_week_of_year (GDate *d)
g_date_get_monday_week_of_year (GDate *d)
{
GDateWeekday wd;
guint day;
......@@ -362,14 +362,14 @@ g_date_monday_week_of_year (GDate *d)
g_date_set_dmy (&first, 1, 1, d->year);
wd = g_date_weekday (&first) - 1; /* make Monday day 0 */
day = g_date_day_of_year (d) - 1;
wd = g_date_get_weekday (&first) - 1; /* make Monday day 0 */
day = g_date_get_day_of_year (d) - 1;
return ((day + wd)/7U + (wd == 0 ? 1 : 0));
}
guint
g_date_sunday_week_of_year (GDate *d)
g_date_get_sunday_week_of_year (GDate *d)
{
GDateWeekday wd;
guint day;
......@@ -388,9 +388,9 @@ g_date_sunday_week_of_year (GDate *d)
g_date_set_dmy (&first, 1, 1, d->year);
wd = g_date_weekday (&first);
wd = g_date_get_weekday (&first);
if (wd == 7) wd = 0; /* make Sunday day 0 */
day = g_date_day_of_year (d) - 1;
day = g_date_get_day_of_year (d) - 1;
return ((day + wd)/7U + (wd == 0 ? 1 : 0));
}
......@@ -1119,8 +1119,8 @@ g_date_is_leap_year (GDateYear year)
}
guint8
g_date_days_in_month (GDateMonth month,
GDateYear year)
g_date_get_days_in_month (GDateMonth month,
GDateYear year)
{
gint index;
......@@ -1133,7 +1133,7 @@ g_date_days_in_month (GDateMonth month,
}
guint8
g_date_monday_weeks_in_year (GDateYear year)
g_date_get_monday_weeks_in_year (GDateYear year)
{
GDate d;
......@@ -1141,21 +1141,21 @@ g_date_monday_weeks_in_year (GDateYear year)
g_date_clear (&d, 1);
g_date_set_dmy (&d, 1, 1, year);
if (g_date_weekday (&d) == G_DATE_MONDAY) return 53;
if (g_date_get_weekday (&d) == G_DATE_MONDAY) return 53;
g_date_set_dmy (&d, 31, 12, year);
if (g_date_weekday (&d) == G_DATE_MONDAY) return 53;
if (g_date_get_weekday (&d) == G_DATE_MONDAY) return 53;
if (g_date_is_leap_year (year))
{
g_date_set_dmy (&d, 2, 1, year);
if (g_date_weekday (&d) == G_DATE_MONDAY) return 53;
if (g_date_get_weekday (&d) == G_DATE_MONDAY) return 53;
g_date_set_dmy (&d, 30, 12, year);
if (g_date_weekday (&d) == G_DATE_MONDAY) return 53;
if (g_date_get_weekday (&d) == G_DATE_MONDAY) return 53;
}
return 52;
}
guint8
g_date_sunday_weeks_in_year (GDateYear year)
g_date_get_sunday_weeks_in_year (GDateYear year)
{
GDate d;
......@@ -1163,15 +1163,15 @@ g_date_sunday_weeks_in_year (GDateYear year)
g_date_clear (&d, 1);
g_date_set_dmy (&d, 1, 1, year);
if (g_date_weekday (&d) == G_DATE_SUNDAY) return 53;
if (g_date_get_weekday (&d) == G_DATE_SUNDAY) return 53;
g_date_set_dmy (&d, 31, 12, year);
if (g_date_weekday (&d) == G_DATE_SUNDAY) return 53;
if (g_date_get_weekday (&d) == G_DATE_SUNDAY) return 53;
if (g_date_is_leap_year (year))
{
g_date_set_dmy (&d, 2, 1, year);
if (g_date_weekday (&d) == G_DATE_SUNDAY) return 53;
if (g_date_get_weekday (&d) == G_DATE_SUNDAY) return 53;
g_date_set_dmy (&d, 30, 12, year);
if (g_date_weekday (&d) == G_DATE_SUNDAY) return 53;
if (g_date_get_weekday (&d) == G_DATE_SUNDAY) return 53;
}
return 52;
}
......@@ -1257,12 +1257,12 @@ g_date_to_struct_tm (GDate *d,
tm->tm_mon = d->month - 1; /* 0-11 goes in tm */
tm->tm_year = ((int)d->year) - 1900; /* X/Open says tm_year can be negative */
day = g_date_weekday (d);
day = g_date_get_weekday (d);
if (day == 7) day = 0; /* struct tm wants days since Sunday, so Sunday is 0 */
tm->tm_wday = (int)day;
tm->tm_yday = g_date_day_of_year (d) - 1; /* 0 to 365 */
tm->tm_yday = g_date_get_day_of_year (d) - 1; /* 0 to 365 */
tm->tm_isdst = -1; /* -1 means "information not available" */
}
......
......@@ -136,20 +136,20 @@ gboolean g_date_valid_dmy (GDateDay day,
GDateMonth month,
GDateYear year) G_GNUC_CONST;
GDateWeekday g_date_weekday (GDate *date);
GDateMonth g_date_month (GDate *date);
GDateYear g_date_year (GDate *date);
GDateDay g_date_day (GDate *date);
guint32 g_date_julian (GDate *date);
guint g_date_day_of_year (GDate *date);
GDateWeekday g_date_get_weekday (GDate *date);
GDateMonth g_date_get_month (GDate *date);
GDateYear g_date_get_year (GDate *date);
GDateDay g_date_get_day (GDate *date);
guint32 g_date_get_julian (GDate *date);
guint g_date_get_day_of_year (GDate *date);
/* First monday/sunday is the start of week 1; if we haven't reached
* that day, return 0. These are not ISO weeks of the year; that
* routine needs to be added.
* these functions return the number of weeks, starting on the
* corrsponding day
*/