From 855e230f318c246537cc2dd606a2e7738a7ea9a8 Mon Sep 17 00:00:00 2001 From: Ali Abdin Date: Sun, 24 Dec 2000 12:11:06 +0000 Subject: [PATCH] New gcompat.h header file as recommended by Havoc. 2000-12-24 Ali Abdin * 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. --- ChangeLog | 11 ++++ ChangeLog.pre-2-0 | 11 ++++ ChangeLog.pre-2-10 | 11 ++++ ChangeLog.pre-2-12 | 11 ++++ ChangeLog.pre-2-2 | 11 ++++ ChangeLog.pre-2-4 | 11 ++++ ChangeLog.pre-2-6 | 11 ++++ ChangeLog.pre-2-8 | 11 ++++ Makefile.am | 4 +- docs/reference/glib/glib-sections.txt | 22 +++---- docs/reference/glib/tmpl/date.sgml | 22 +++---- gcompat.h | 45 +++++++++++++ gdate.c | 52 +++++++-------- gdate.h | 22 +++---- glib.h | 1 + glib/Makefile.am | 4 +- glib/gdate.c | 52 +++++++-------- glib/gdate.h | 22 +++---- glib/glib.h | 1 + testgdate.c | 94 +++++++++++++-------------- tests/date-test.c | 94 +++++++++++++-------------- tests/testgdate.c | 94 +++++++++++++-------------- 22 files changed, 378 insertions(+), 239 deletions(-) create mode 100644 gcompat.h diff --git a/ChangeLog b/ChangeLog index 3e2ce7884..a7dfc16b4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2000-12-24 Ali Abdin + + * 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 * configure.in: Determine the suffix of the shared librarries for diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 3e2ce7884..a7dfc16b4 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,14 @@ +2000-12-24 Ali Abdin + + * 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 * configure.in: Determine the suffix of the shared librarries for diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 3e2ce7884..a7dfc16b4 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,14 @@ +2000-12-24 Ali Abdin + + * 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 * configure.in: Determine the suffix of the shared librarries for diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 3e2ce7884..a7dfc16b4 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,14 @@ +2000-12-24 Ali Abdin + + * 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 * configure.in: Determine the suffix of the shared librarries for diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 3e2ce7884..a7dfc16b4 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,14 @@ +2000-12-24 Ali Abdin + + * 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 * configure.in: Determine the suffix of the shared librarries for diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 3e2ce7884..a7dfc16b4 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,14 @@ +2000-12-24 Ali Abdin + + * 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 * configure.in: Determine the suffix of the shared librarries for diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 3e2ce7884..a7dfc16b4 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,14 @@ +2000-12-24 Ali Abdin + + * 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 * configure.in: Determine the suffix of the shared librarries for diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 3e2ce7884..a7dfc16b4 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,14 @@ +2000-12-24 Ali Abdin + + * 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 * configure.in: Determine the suffix of the shared librarries for diff --git a/Makefile.am b/Makefile.am index a4224af38..d8e0068da 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 \ diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt index 3eb8f1190..bc595353d 100644 --- a/docs/reference/glib/glib-sections.txt +++ b/docs/reference/glib/glib-sections.txt @@ -879,22 +879,22 @@ g_date_subtract_years g_date_compare -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 -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 g_date_strftime diff --git a/docs/reference/glib/tmpl/date.sgml b/docs/reference/glib/tmpl/date.sgml index ac82029ac..60f27af09 100644 --- a/docs/reference/glib/tmpl/date.sgml +++ b/docs/reference/glib/tmpl/date.sgml @@ -422,7 +422,7 @@ dates must be valid. greater than zero if @lhs is greater than @rhs - + Return the day of the month; the #GDate must be valid. @@ -431,7 +431,7 @@ Return the day of the month; the #GDate must be valid. @Returns: Day of the month - + Accessor for the month of the year. Date must be valid. @@ -440,7 +440,7 @@ Accessor for the month of the year. Date must be valid. @Returns: A #GDateMonth - + Accessor; returns the year of a #GDate. The date must be valid. @@ -449,7 +449,7 @@ Accessor; returns the year of a #GDate. The date must be valid. @Returns: Year in which the date falls - + 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 - + Returns the day of the week for a #GDate. The date must be valid. @@ -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 - + 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 - + Return the number of days in a month, taking leap years into account. @@ -517,7 +517,7 @@ Returns TRUE if the year is a leap year @Returns: Boolean, if the year is a leap year - + 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 - + 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 - + 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 - + 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 diff --git a/gcompat.h b/gcompat.h new file mode 100644 index 000000000..10ef4457e --- /dev/null +++ b/gcompat.h @@ -0,0 +1,45 @@ +/* GLIB - Library of useful routines for C programming + * + * Copyright (C) 2000 Ali Abdin + * + * 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 + +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__ */ diff --git a/gdate.c b/gdate.c index ac5992758..708c4705b 100644 --- a/gdate.c +++ b/gdate.c @@ -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" */ } diff --git a/gdate.h b/gdate.h index 149eace4e..c5fa2dc2c 100644 --- a/gdate.h +++ b/gdate.h @@ -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, diff --git a/glib.h b/glib.h index b85bac04e..689f2e869 100644 --- a/glib.h +++ b/glib.h @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include diff --git a/glib/Makefile.am b/glib/Makefile.am index a4224af38..d8e0068da 100644 --- a/glib/Makefile.am +++ b/glib/Makefile.am @@ -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 \ diff --git a/glib/gdate.c b/glib/gdate.c index ac5992758..708c4705b 100644 --- a/glib/gdate.c +++ b/glib/gdate.c @@ -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" */ } diff --git a/glib/gdate.h b/glib/gdate.h index 149eace4e..c5fa2dc2c 100644 --- a/glib/gdate.h +++ b/glib/gdate.h @@ -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, diff --git a/glib/glib.h b/glib/glib.h index b85bac04e..689f2e869 100644 --- a/glib/glib.h +++ b/glib/glib.h @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include diff --git a/testgdate.c b/testgdate.c index f74e00a3b..8e3f75066 100644 --- a/testgdate.c +++ b/testgdate.c @@ -80,13 +80,13 @@ int main(int argc, char** argv) TEST("January 1, Year 1 created and valid", g_date_valid(d)); - j = g_date_julian(d); + j = g_date_get_julian(d); TEST("January 1, Year 1 is Julian date 1", j == 1); - TEST("Returned month is January", g_date_month(d) == G_DATE_JANUARY); - TEST("Returned day is 1", g_date_day(d) == 1); - TEST("Returned year is 1", g_date_year(d) == 1); + TEST("Returned month is January", g_date_get_month(d) == G_DATE_JANUARY); + TEST("Returned day is 1", g_date_get_day(d) == 1); + TEST("Returned year is 1", g_date_get_year(d) == 1); TEST("Bad month is invalid", !g_date_valid_month(G_DATE_BAD_MONTH)); TEST("Month 13 is invalid", !g_date_valid_month(13)); @@ -138,9 +138,9 @@ int main(int argc, char** argv) /* Note: this test will hopefully work, but no promises. */ TEST("Successfully parsed a %x-formatted string", g_date_valid(d) && - g_date_month(d) == 1 && - g_date_day(d) == 10 && - g_date_year(d) == 2000); + g_date_get_month(d) == 1 && + g_date_get_day(d) == 10 && + g_date_get_year(d) == 2000); if (failed) g_date_debug_print(d); @@ -157,9 +157,9 @@ int main(int argc, char** argv) guint32 first_day_of_year = G_DATE_BAD_JULIAN; guint16 days_in_year = g_date_is_leap_year(y) ? 366 : 365; guint sunday_week_of_year = 0; - guint sunday_weeks_in_year = g_date_sunday_weeks_in_year(y); + guint sunday_weeks_in_year = g_date_get_sunday_weeks_in_year(y); guint monday_week_of_year = 0; - guint monday_weeks_in_year = g_date_monday_weeks_in_year(y); + guint monday_weeks_in_year = g_date_get_monday_weeks_in_year(y); if (discontinuity) g_print(" (Break in sequence of requested years to check)\n"); @@ -177,7 +177,7 @@ int main(int argc, char** argv) m = 1; while (m < 13) { - guint8 dim = g_date_days_in_month(m,y); + guint8 dim = g_date_get_days_in_month(m,y); GDate days[31]; /* This is the fast way, no allocation */ TEST("Sensible number of days in month", (dim > 0 && dim < 32)); @@ -207,89 +207,89 @@ int main(int argc, char** argv) if (m == G_DATE_JANUARY && day == 1) { - first_day_of_year = g_date_julian(d); + first_day_of_year = g_date_get_julian(d); } g_assert(first_day_of_year != G_DATE_BAD_JULIAN); TEST("Date with DMY triplet is valid", g_date_valid(d)); - TEST("Month accessor works", g_date_month(d) == m); - TEST("Year accessor works", g_date_year(d) == y); - TEST("Day of month accessor works", g_date_day(d) == day); + TEST("Month accessor works", g_date_get_month(d) == m); + TEST("Year accessor works", g_date_get_year(d) == y); + TEST("Day of month accessor works", g_date_get_day(d) == day); TEST("Day of year is consistent with Julian dates", - ((g_date_julian(d) + 1 - first_day_of_year) == - (g_date_day_of_year(d)))); + ((g_date_get_julian(d) + 1 - first_day_of_year) == + (g_date_get_day_of_year(d)))); if (failed) { g_print("first day: %u this day: %u day of year: %u\n", first_day_of_year, - g_date_julian(d), - g_date_day_of_year(d)); + g_date_get_julian(d), + g_date_get_day_of_year(d)); } if (m == G_DATE_DECEMBER && day == 31) { TEST("Last day of year equals number of days in year", - g_date_day_of_year(d) == days_in_year); + g_date_get_day_of_year(d) == days_in_year); if (failed) { g_print("last day: %u days in year: %u\n", - g_date_day_of_year(d), days_in_year); + g_date_get_day_of_year(d), days_in_year); } } TEST("Day of year is not more than number of days in the year", - g_date_day_of_year(d) <= days_in_year); + g_date_get_day_of_year(d) <= days_in_year); TEST("Monday week of year is not more than number of weeks in the year", - g_date_monday_week_of_year(d) <= monday_weeks_in_year); + g_date_get_monday_week_of_year(d) <= monday_weeks_in_year); if (failed) { g_print("Weeks in year: %u\n", monday_weeks_in_year); g_date_debug_print(d); } TEST("Monday week of year is >= than last week of year", - g_date_monday_week_of_year(d) >= monday_week_of_year); + g_date_get_monday_week_of_year(d) >= monday_week_of_year); - if (g_date_weekday(d) == G_DATE_MONDAY) + if (g_date_get_weekday(d) == G_DATE_MONDAY) { TEST("Monday week of year on Monday 1 more than previous day's week of year", - (g_date_monday_week_of_year(d) - monday_week_of_year) == 1); + (g_date_get_monday_week_of_year(d) - monday_week_of_year) == 1); } else { TEST("Monday week of year on non-Monday 0 more than previous day's week of year", - (g_date_monday_week_of_year(d) - monday_week_of_year) == 0); + (g_date_get_monday_week_of_year(d) - monday_week_of_year) == 0); } - monday_week_of_year = g_date_monday_week_of_year(d); + monday_week_of_year = g_date_get_monday_week_of_year(d); TEST("Sunday week of year is not more than number of weeks in the year", - g_date_sunday_week_of_year(d) <= sunday_weeks_in_year); + g_date_get_sunday_week_of_year(d) <= sunday_weeks_in_year); if (failed) { g_date_debug_print(d); } TEST("Sunday week of year is >= than last week of year", - g_date_sunday_week_of_year(d) >= sunday_week_of_year); + g_date_get_sunday_week_of_year(d) >= sunday_week_of_year); - if (g_date_weekday(d) == G_DATE_SUNDAY) + if (g_date_get_weekday(d) == G_DATE_SUNDAY) { TEST("Sunday week of year on Sunday 1 more than previous day's week of year", - (g_date_sunday_week_of_year(d) - sunday_week_of_year) == 1); + (g_date_get_sunday_week_of_year(d) - sunday_week_of_year) == 1); } else { TEST("Sunday week of year on non-Sunday 0 more than previous day's week of year", - (g_date_sunday_week_of_year(d) - sunday_week_of_year) == 0); + (g_date_get_sunday_week_of_year(d) - sunday_week_of_year) == 0); } - sunday_week_of_year = g_date_sunday_week_of_year(d); + sunday_week_of_year = g_date_get_sunday_week_of_year(d); TEST("Date is equal to itself", g_date_compare(d,d) == 0); @@ -310,7 +310,7 @@ int main(int argc, char** argv) g_date_subtract_days(d, i); TEST("Forward days then backward days returns us to current day", - g_date_day(d) == day); + g_date_get_day(d) == day); if (failed) { @@ -319,7 +319,7 @@ int main(int argc, char** argv) } TEST("Forward days then backward days returns us to current month", - g_date_month(d) == m); + g_date_get_month(d) == m); if (failed) { @@ -328,7 +328,7 @@ int main(int argc, char** argv) } TEST("Forward days then backward days returns us to current year", - g_date_year(d) == y); + g_date_get_year(d) == y); if (failed) { @@ -345,7 +345,7 @@ int main(int argc, char** argv) g_date_subtract_months(d, i); TEST("Forward months then backward months returns us to current month", - g_date_month(d) == m); + g_date_get_month(d) == m); if (failed) { @@ -354,7 +354,7 @@ int main(int argc, char** argv) } TEST("Forward months then backward months returns us to current year", - g_date_year(d) == y); + g_date_get_year(d) == y); if (failed) { @@ -368,7 +368,7 @@ int main(int argc, char** argv) /* Day should be unchanged */ TEST("Forward months then backward months returns us to current day", - g_date_day(d) == day); + g_date_get_day(d) == day); if (failed) { @@ -393,7 +393,7 @@ int main(int argc, char** argv) g_date_subtract_years(d, i); TEST("Forward years then backward years returns us to current month", - g_date_month(d) == m); + g_date_get_month(d) == m); if (failed) { @@ -402,7 +402,7 @@ int main(int argc, char** argv) } TEST("Forward years then backward years returns us to current year", - g_date_year(d) == y); + g_date_get_year(d) == y); if (failed) { @@ -413,7 +413,7 @@ int main(int argc, char** argv) if (m != 2 && day != 29) { TEST("Forward years then backward years returns us to current day", - g_date_day(d) == day); + g_date_get_day(d) == day); if (failed) { @@ -436,16 +436,16 @@ int main(int argc, char** argv) /* We can only run sequence tests between sequential years */ TEST("Julians are sequential with increment 1", - j+1 == g_date_julian(d)); + j+1 == g_date_get_julian(d)); if (failed) { g_print("Out of sequence, prev: %u expected: %u got: %u\n", - j, j+1, g_date_julian(d)); + j, j+1, g_date_get_julian(d)); } g_date_add_days(d,1); TEST("Next day has julian 1 higher", - g_date_julian(d) == j + 2); + g_date_get_julian(d) == j + 2); g_date_subtract_days(d, 1); if (j != G_DATE_BAD_JULIAN) @@ -453,7 +453,7 @@ int main(int argc, char** argv) g_date_subtract_days(d, 1); TEST("Previous day has julian 1 lower", - g_date_julian(d) == j); + g_date_get_julian(d) == j); g_date_add_days(d, 1); /* back to original */ } @@ -463,7 +463,7 @@ int main(int argc, char** argv) fflush(stdout); fflush(stderr); - j = g_date_julian(d); /* inc current julian */ + j = g_date_get_julian(d); /* inc current julian */ ++day; } diff --git a/tests/date-test.c b/tests/date-test.c index e181edd5d..ba405ea94 100644 --- a/tests/date-test.c +++ b/tests/date-test.c @@ -77,13 +77,13 @@ int main(int argc, char** argv) TEST("January 1, Year 1 created and valid", g_date_valid(d)); - j = g_date_julian(d); + j = g_date_get_julian(d); TEST("January 1, Year 1 is Julian date 1", j == 1); - TEST("Returned month is January", g_date_month(d) == G_DATE_JANUARY); - TEST("Returned day is 1", g_date_day(d) == 1); - TEST("Returned year is 1", g_date_year(d) == 1); + TEST("Returned month is January", g_date_get_month(d) == G_DATE_JANUARY); + TEST("Returned day is 1", g_date_get_day(d) == 1); + TEST("Returned year is 1", g_date_get_year(d) == 1); TEST("Bad month is invalid", !g_date_valid_month(G_DATE_BAD_MONTH)); TEST("Month 13 is invalid", !g_date_valid_month(13)); @@ -135,9 +135,9 @@ int main(int argc, char** argv) /* Note: this test will hopefully work, but no promises. */ TEST("Successfully parsed a %x-formatted string", g_date_valid(d) && - g_date_month(d) == 1 && - g_date_day(d) == 10 && - g_date_year(d) == 2000); + g_date_get_month(d) == 1 && + g_date_get_day(d) == 10 && + g_date_get_year(d) == 2000); if (failed) g_date_debug_print(d); @@ -154,9 +154,9 @@ int main(int argc, char** argv) guint32 first_day_of_year = G_DATE_BAD_JULIAN; guint16 days_in_year = g_date_is_leap_year(y) ? 366 : 365; guint sunday_week_of_year = 0; - guint sunday_weeks_in_year = g_date_sunday_weeks_in_year(y); + guint sunday_weeks_in_year = g_date_get_sunday_weeks_in_year(y); guint monday_week_of_year = 0; - guint monday_weeks_in_year = g_date_monday_weeks_in_year(y); + guint monday_weeks_in_year = g_date_get_monday_weeks_in_year(y); if (discontinuity) g_print(" (Break in sequence of requested years to check)\n"); @@ -174,7 +174,7 @@ int main(int argc, char** argv) m = 1; while (m < 13) { - guint8 dim = g_date_days_in_month(m,y); + guint8 dim = g_date_get_days_in_month(m,y); GDate days[31]; /* This is the fast way, no allocation */ TEST("Sensible number of days in month", (dim > 0 && dim < 32)); @@ -204,89 +204,89 @@ int main(int argc, char** argv) if (m == G_DATE_JANUARY && day == 1) { - first_day_of_year = g_date_julian(d); + first_day_of_year = g_date_get_julian(d); } g_assert(first_day_of_year != G_DATE_BAD_JULIAN); TEST("Date with DMY triplet is valid", g_date_valid(d)); - TEST("Month accessor works", g_date_month(d) == m); - TEST("Year accessor works", g_date_year(d) == y); - TEST("Day of month accessor works", g_date_day(d) == day); + TEST("Month accessor works", g_date_get_month(d) == m); + TEST("Year accessor works", g_date_get_year(d) == y); + TEST("Day of month accessor works", g_date_get_day(d) == day); TEST("Day of year is consistent with Julian dates", - ((g_date_julian(d) + 1 - first_day_of_year) == - (g_date_day_of_year(d)))); + ((g_date_get_julian(d) + 1 - first_day_of_year) == + (g_date_get_day_of_year(d)))); if (failed) { g_print("first day: %u this day: %u day of year: %u\n", first_day_of_year, - g_date_julian(d), - g_date_day_of_year(d)); + g_date_get_julian(d), + g_date_get_day_of_year(d)); } if (m == G_DATE_DECEMBER && day == 31) { TEST("Last day of year equals number of days in year", - g_date_day_of_year(d) == days_in_year); + g_date_get_day_of_year(d) == days_in_year); if (failed) { g_print("last day: %u days in year: %u\n", - g_date_day_of_year(d), days_in_year); + g_date_get_day_of_year(d), days_in_year); } } TEST("Day of year is not more than number of days in the year", - g_date_day_of_year(d) <= days_in_year); + g_date_get_day_of_year(d) <= days_in_year); TEST("Monday week of year is not more than number of weeks in the year", - g_date_monday_week_of_year(d) <= monday_weeks_in_year); + g_date_get_monday_week_of_year(d) <= monday_weeks_in_year); if (failed) { g_print("Weeks in year: %u\n", monday_weeks_in_year); g_date_debug_print(d); } TEST("Monday week of year is >= than last week of year", - g_date_monday_week_of_year(d) >= monday_week_of_year); + g_date_get_monday_week_of_year(d) >= monday_week_of_year); - if (g_date_weekday(d) == G_DATE_MONDAY) + if (g_date_get_weekday(d) == G_DATE_MONDAY) { TEST("Monday week of year on Monday 1 more than previous day's week of year", - (g_date_monday_week_of_year(d) - monday_week_of_year) == 1); + (g_date_get_monday_week_of_year(d) - monday_week_of_year) == 1); } else { TEST("Monday week of year on non-Monday 0 more than previous day's week of year", - (g_date_monday_week_of_year(d) - monday_week_of_year) == 0); + (g_date_get_monday_week_of_year(d) - monday_week_of_year) == 0); } - monday_week_of_year = g_date_monday_week_of_year(d); + monday_week_of_year = g_date_get_monday_week_of_year(d); TEST("Sunday week of year is not more than number of weeks in the year", - g_date_sunday_week_of_year(d) <= sunday_weeks_in_year); + g_date_get_sunday_week_of_year(d) <= sunday_weeks_in_year); if (failed) { g_date_debug_print(d); } TEST("Sunday week of year is >= than last week of year", - g_date_sunday_week_of_year(d) >= sunday_week_of_year); + g_date_get_sunday_week_of_year(d) >= sunday_week_of_year); - if (g_date_weekday(d) == G_DATE_SUNDAY) + if (g_date_get_weekday(d) == G_DATE_SUNDAY) { TEST("Sunday week of year on Sunday 1 more than previous day's week of year", - (g_date_sunday_week_of_year(d) - sunday_week_of_year) == 1); + (g_date_get_sunday_week_of_year(d) - sunday_week_of_year) == 1); } else { TEST("Sunday week of year on non-Sunday 0 more than previous day's week of year", - (g_date_sunday_week_of_year(d) - sunday_week_of_year) == 0); + (g_date_get_sunday_week_of_year(d) - sunday_week_of_year) == 0); } - sunday_week_of_year = g_date_sunday_week_of_year(d); + sunday_week_of_year = g_date_get_sunday_week_of_year(d); TEST("Date is equal to itself", g_date_compare(d,d) == 0); @@ -307,7 +307,7 @@ int main(int argc, char** argv) g_date_subtract_days(d, i); TEST("Forward days then backward days returns us to current day", - g_date_day(d) == day); + g_date_get_day(d) == day); if (failed) { @@ -316,7 +316,7 @@ int main(int argc, char** argv) } TEST("Forward days then backward days returns us to current month", - g_date_month(d) == m); + g_date_get_month(d) == m); if (failed) { @@ -325,7 +325,7 @@ int main(int argc, char** argv) } TEST("Forward days then backward days returns us to current year", - g_date_year(d) == y); + g_date_get_year(d) == y); if (failed) { @@ -342,7 +342,7 @@ int main(int argc, char** argv) g_date_subtract_months(d, i); TEST("Forward months then backward months returns us to current month", - g_date_month(d) == m); + g_date_get_month(d) == m); if (failed) { @@ -351,7 +351,7 @@ int main(int argc, char** argv) } TEST("Forward months then backward months returns us to current year", - g_date_year(d) == y); + g_date_get_year(d) == y); if (failed) { @@ -365,7 +365,7 @@ int main(int argc, char** argv) /* Day should be unchanged */ TEST("Forward months then backward months returns us to current day", - g_date_day(d) == day); + g_date_get_day(d) == day); if (failed) { @@ -390,7 +390,7 @@ int main(int argc, char** argv) g_date_subtract_years(d, i); TEST("Forward years then backward years returns us to current month", - g_date_month(d) == m); + g_date_get_month(d) == m); if (failed) { @@ -399,7 +399,7 @@ int main(int argc, char** argv) } TEST("Forward years then backward years returns us to current year", - g_date_year(d) == y); + g_date_get_year(d) == y); if (failed) { @@ -410,7 +410,7 @@ int main(int argc, char** argv) if (m != 2 && day != 29) { TEST("Forward years then backward years returns us to current day", - g_date_day(d) == day); + g_date_get_day(d) == day); if (failed) { @@ -433,16 +433,16 @@ int main(int argc, char** argv) /* We can only run sequence tests between sequential years */ TEST("Julians are sequential with increment 1", - j+1 == g_date_julian(d)); + j+1 == g_date_get_julian(d)); if (failed) { g_print("Out of sequence, prev: %u expected: %u got: %u\n", - j, j+1, g_date_julian(d)); + j, j+1, g_date_get_julian(d)); } g_date_add_days(d,1); TEST("Next day has julian 1 higher", - g_date_julian(d) == j + 2); + g_date_get_julian(d) == j + 2); g_date_subtract_days(d, 1); if (j != G_DATE_BAD_JULIAN) @@ -450,7 +450,7 @@ int main(int argc, char** argv) g_date_subtract_days(d, 1); TEST("Previous day has julian 1 lower", - g_date_julian(d) == j); + g_date_get_julian(d) == j); g_date_add_days(d, 1); /* back to original */ } @@ -460,7 +460,7 @@ int main(int argc, char** argv) fflush(stdout); fflush(stderr); - j = g_date_julian(d); /* inc current julian */ + j = g_date_get_julian(d); /* inc current julian */ ++day; } diff --git a/tests/testgdate.c b/tests/testgdate.c index f74e00a3b..8e3f75066 100644 --- a/tests/testgdate.c +++ b/tests/testgdate.c @@ -80,13 +80,13 @@ int main(int argc, char** argv) TEST("January 1, Year 1 created and valid", g_date_valid(d)); - j = g_date_julian(d); + j = g_date_get_julian(d); TEST("January 1, Year 1 is Julian date 1", j == 1); - TEST("Returned month is January", g_date_month(d) == G_DATE_JANUARY); - TEST("Returned day is 1", g_date_day(d) == 1); - TEST("Returned year is 1", g_date_year(d) == 1); + TEST("Returned month is January", g_date_get_month(d) == G_DATE_JANUARY); + TEST("Returned day is 1", g_date_get_day(d) == 1); + TEST("Returned year is 1", g_date_get_year(d) == 1); TEST("Bad month is invalid", !g_date_valid_month(G_DATE_BAD_MONTH)); TEST("Month 13 is invalid", !g_date_valid_month(13)); @@ -138,9 +138,9 @@ int main(int argc, char** argv) /* Note: this test will hopefully work, but no promises. */ TEST("Successfully parsed a %x-formatted string", g_date_valid(d) && - g_date_month(d) == 1 && - g_date_day(d) == 10 && - g_date_year(d) == 2000); + g_date_get_month(d) == 1 && + g_date_get_day(d) == 10 && + g_date_get_year(d) == 2000); if (failed) g_date_debug_print(d); @@ -157,9 +157,9 @@ int main(int argc, char** argv) guint32 first_day_of_year = G_DATE_BAD_JULIAN; guint16 days_in_year = g_date_is_leap_year(y) ? 366 : 365; guint sunday_week_of_year = 0; - guint sunday_weeks_in_year = g_date_sunday_weeks_in_year(y); + guint sunday_weeks_in_year = g_date_get_sunday_weeks_in_year(y); guint monday_week_of_year = 0; - guint monday_weeks_in_year = g_date_monday_weeks_in_year(y); + guint monday_weeks_in_year = g_date_get_monday_weeks_in_year(y); if (discontinuity) g_print(" (Break in sequence of requested years to check)\n"); @@ -177,7 +177,7 @@ int main(int argc, char** argv) m = 1; while (m < 13) { - guint8 dim = g_date_days_in_month(m,y); + guint8 dim = g_date_get_days_in_month(m,y); GDate days[31]; /* This is the fast way, no allocation */ TEST("Sensible number of days in month", (dim > 0 && dim < 32)); @@ -207,89 +207,89 @@ int main(int argc, char** argv) if (m == G_DATE_JANUARY && day == 1) { - first_day_of_year = g_date_julian(d); + first_day_of_year = g_date_get_julian(d); } g_assert(first_day_of_year != G_DATE_BAD_JULIAN); TEST("Date with DMY triplet is valid", g_date_valid(d)); - TEST("Month accessor works", g_date_month(d) == m); - TEST("Year accessor works", g_date_year(d) == y); - TEST("Day of month accessor works", g_date_day(d) == day); + TEST("Month accessor works", g_date_get_month(d) == m); + TEST("Year accessor works", g_date_get_year(d) == y); + TEST("Day of month accessor works", g_date_get_day(d) == day); TEST("Day of year is consistent with Julian dates", - ((g_date_julian(d) + 1 - first_day_of_year) == - (g_date_day_of_year(d)))); + ((g_date_get_julian(d) + 1 - first_day_of_year) == + (g_date_get_day_of_year(d)))); if (failed) { g_print("first day: %u this day: %u day of year: %u\n", first_day_of_year, - g_date_julian(d), - g_date_day_of_year(d)); + g_date_get_julian(d), + g_date_get_day_of_year(d)); } if (m == G_DATE_DECEMBER && day == 31) { TEST("Last day of year equals number of days in year", - g_date_day_of_year(d) == days_in_year); + g_date_get_day_of_year(d) == days_in_year); if (failed) { g_print("last day: %u days in year: %u\n", - g_date_day_of_year(d), days_in_year); + g_date_get_day_of_year(d), days_in_year); } } TEST("Day of year is not more than number of days in the year", - g_date_day_of_year(d) <= days_in_year); + g_date_get_day_of_year(d) <= days_in_year); TEST("Monday week of year is not more than number of weeks in the year", - g_date_monday_week_of_year(d) <= monday_weeks_in_year); + g_date_get_monday_week_of_year(d) <= monday_weeks_in_year); if (failed) { g_print("Weeks in year: %u\n", monday_weeks_in_year); g_date_debug_print(d); } TEST("Monday week of year is >= than last week of year", - g_date_monday_week_of_year(d) >= monday_week_of_year); + g_date_get_monday_week_of_year(d) >= monday_week_of_year); - if (g_date_weekday(d) == G_DATE_MONDAY) + if (g_date_get_weekday(d) == G_DATE_MONDAY) { TEST("Monday week of year on Monday 1 more than previous day's week of year", - (g_date_monday_week_of_year(d) - monday_week_of_year) == 1); + (g_date_get_monday_week_of_year(d) - monday_week_of_year) == 1); } else { TEST("Monday week of year on non-Monday 0 more than previous day's week of year", - (g_date_monday_week_of_year(d) - monday_week_of_year) == 0); + (g_date_get_monday_week_of_year(d) - monday_week_of_year) == 0); } - monday_week_of_year = g_date_monday_week_of_year(d); + monday_week_of_year = g_date_get_monday_week_of_year(d); TEST("Sunday week of year is not more than number of weeks in the year", - g_date_sunday_week_of_year(d) <= sunday_weeks_in_year); + g_date_get_sunday_week_of_year(d) <= sunday_weeks_in_year); if (failed) { g_date_debug_print(d); } TEST("Sunday week of year is >= than last week of year", - g_date_sunday_week_of_year(d) >= sunday_week_of_year); + g_date_get_sunday_week_of_year(d) >= sunday_week_of_year); - if (g_date_weekday(d) == G_DATE_SUNDAY) + if (g_date_get_weekday(d) == G_DATE_SUNDAY) { TEST("Sunday week of year on Sunday 1 more than previous day's week of year", - (g_date_sunday_week_of_year(d) - sunday_week_of_year) == 1); + (g_date_get_sunday_week_of_year(d) - sunday_week_of_year) == 1); } else { TEST("Sunday week of year on non-Sunday 0 more than previous day's week of year", - (g_date_sunday_week_of_year(d) - sunday_week_of_year) == 0); + (g_date_get_sunday_week_of_year(d) - sunday_week_of_year) == 0); } - sunday_week_of_year = g_date_sunday_week_of_year(d); + sunday_week_of_year = g_date_get_sunday_week_of_year(d); TEST("Date is equal to itself", g_date_compare(d,d) == 0); @@ -310,7 +310,7 @@ int main(int argc, char** argv) g_date_subtract_days(d, i); TEST("Forward days then backward days returns us to current day", - g_date_day(d) == day); + g_date_get_day(d) == day); if (failed) { @@ -319,7 +319,7 @@ int main(int argc, char** argv) } TEST("Forward days then backward days returns us to current month", - g_date_month(d) == m); + g_date_get_month(d) == m); if (failed) { @@ -328,7 +328,7 @@ int main(int argc, char** argv) } TEST("Forward days then backward days returns us to current year", - g_date_year(d) == y); + g_date_get_year(d) == y); if (failed) { @@ -345,7 +345,7 @@ int main(int argc, char** argv) g_date_subtract_months(d, i); TEST("Forward months then backward months returns us to current month", - g_date_month(d) == m); + g_date_get_month(d) == m); if (failed) { @@ -354,7 +354,7 @@ int main(int argc, char** argv) } TEST("Forward months then backward months returns us to current year", - g_date_year(d) == y); + g_date_get_year(d) == y); if (failed) { @@ -368,7 +368,7 @@ int main(int argc, char** argv) /* Day should be unchanged */ TEST("Forward months then backward months returns us to current day", - g_date_day(d) == day); + g_date_get_day(d) == day); if (failed) { @@ -393,7 +393,7 @@ int main(int argc, char** argv) g_date_subtract_years(d, i); TEST("Forward years then backward years returns us to current month", - g_date_month(d) == m); + g_date_get_month(d) == m); if (failed) { @@ -402,7 +402,7 @@ int main(int argc, char** argv) } TEST("Forward years then backward years returns us to current year", - g_date_year(d) == y); + g_date_get_year(d) == y); if (failed) { @@ -413,7 +413,7 @@ int main(int argc, char** argv) if (m != 2 && day != 29) { TEST("Forward years then backward years returns us to current day", - g_date_day(d) == day); + g_date_get_day(d) == day); if (failed) { @@ -436,16 +436,16 @@ int main(int argc, char** argv) /* We can only run sequence tests between sequential years */ TEST("Julians are sequential with increment 1", - j+1 == g_date_julian(d)); + j+1 == g_date_get_julian(d)); if (failed) { g_print("Out of sequence, prev: %u expected: %u got: %u\n", - j, j+1, g_date_julian(d)); + j, j+1, g_date_get_julian(d)); } g_date_add_days(d,1); TEST("Next day has julian 1 higher", - g_date_julian(d) == j + 2); + g_date_get_julian(d) == j + 2); g_date_subtract_days(d, 1); if (j != G_DATE_BAD_JULIAN) @@ -453,7 +453,7 @@ int main(int argc, char** argv) g_date_subtract_days(d, 1); TEST("Previous day has julian 1 lower", - g_date_julian(d) == j); + g_date_get_julian(d) == j); g_date_add_days(d, 1); /* back to original */ } @@ -463,7 +463,7 @@ int main(int argc, char** argv) fflush(stdout); fflush(stderr); - j = g_date_julian(d); /* inc current julian */ + j = g_date_get_julian(d); /* inc current julian */ ++day; }