aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/misc/e-calendar-item.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2003-02-25 15:03:46 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2003-02-25 15:03:46 +0800
commitf446063c572a9278fa3ce8e6b359c541ace68814 (patch)
tree6838d63be3bf113b1cad1d5c139151e289d41566 /widgets/misc/e-calendar-item.c
parentbcc58d8bc72d02a6a54f52fda53f7f4f1d192d6a (diff)
downloadgsoc2013-evolution-f446063c572a9278fa3ce8e6b359c541ace68814.tar.gz
gsoc2013-evolution-f446063c572a9278fa3ce8e6b359c541ace68814.tar.zst
gsoc2013-evolution-f446063c572a9278fa3ce8e6b359c541ace68814.zip
Same as below.
2003-02-25 Jeffrey Stedfast <fejj@ximian.com> * e-dateedit.c (on_date_popup_date_selected): Same as below. * e-cell-date-edit.c (e_cell_date_edit_on_ok_clicked): Also updated to use the new GDate API from glib 2.0 * test-calendar.c (on_selection_changed): Fixed to use glib 2.0's GDate API. * e-calendar-item.c (e_calendar_item_get_week_number): Port to glib 2.0's GDate API. (e_calendar_item_set_selection): Same. * e-search-bar.c (append_xml_menu_item): Use g_string_append_printf instead of g_string_sprintfa since the latter is now deprecated. (setup_bonobo_menus): Same. * e-filter-bar.c (do_advanced): Use gtk_window_set_resizable() * e-charset-picker.c: Fixes to make it build cleanly with -DG_DISABLE_DEPRECATED (add_charset): Escape _'s so we don't get underline weirdness due to GtkLabel thinking the _ means to underline the next char. (e_charset_picker_bonobo_ui_populate): Same here. svn path=/trunk/; revision=20048
Diffstat (limited to 'widgets/misc/e-calendar-item.c')
-rw-r--r--widgets/misc/e-calendar-item.c58
1 files changed, 31 insertions, 27 deletions
diff --git a/widgets/misc/e-calendar-item.c b/widgets/misc/e-calendar-item.c
index 8d3bd80853..3e781a9d3e 100644
--- a/widgets/misc/e-calendar-item.c
+++ b/widgets/misc/e-calendar-item.c
@@ -25,7 +25,10 @@
* ECalendarItem - canvas item displaying a calendar.
*/
+
+#ifdef HAVE_CONFIG_H
#include <config.h>
+#endif
#include "e-calendar-item.h"
@@ -1498,37 +1501,38 @@ e_calendar_item_get_week_number (ECalendarItem *calitem,
gint month,
gint year)
{
- GDate tmp_date;
- gint weekday, yearday, offset, week_num;
-
+ GDate date;
+ guint weekday, yearday;
+ int offset, week_num;
+
/* FIXME: check what happens at year boundaries. */
-
- g_date_clear (&tmp_date, 1);
- g_date_set_dmy (&tmp_date, day, month + 1, year);
-
- /* This results in a value of 0 (Monday) - 6 (Sunday). */
- weekday = g_date_weekday (&tmp_date) - 1;
-
+
+ g_date_clear (&date, 1);
+ g_date_set_dmy (&date, day, month + 1, year);
+
+ /* This results in a value of 0 (Monday) - 6 (Sunday). (or -1 on error - oops!!) */
+ weekday = g_date_get_weekday (&date) - 1;
+
/* Calculate the offset from the start of the week. */
offset = (calitem->week_start_day + 7 - weekday) % 7;
-
+
/* Calculate the day of the year, from 0 to 365. */
- yearday = g_date_day_of_year (&tmp_date) - 1;
-
+ yearday = g_date_get_day_of_year (&date) - 1;
+
/* If the week starts on or after 29th December, it is week 1 of the
next year, since there are 4 days in the next year. */
- g_date_subtract_days (&tmp_date, offset);
- if (g_date_month (&tmp_date) == 12 && g_date_day (&tmp_date) >= 29)
+ g_date_subtract_days (&date, offset);
+ if (g_date_get_month (&date) == 12 && g_date_get_day (&date) >= 29)
return 1;
-
+
/* Calculate the week number, from 0. */
week_num = (yearday - offset) / 7;
-
+
/* If the first week starts on or after Jan 5th, then we need to add
1 since the previous week will really be the first week. */
if ((yearday - offset) % 7 >= 4)
week_num++;
-
+
/* Add 1 so week numbers are from 1 to 53. */
return week_num + 1;
}
@@ -2683,16 +2687,16 @@ e_calendar_item_set_selection (ECalendarItem *calitem,
if (end_date == NULL)
end_date = start_date;
-
+
g_return_if_fail (g_date_compare (start_date, end_date) <= 0);
-
- start_year = g_date_year (start_date);
- start_month = g_date_month (start_date) - 1;
- start_day = g_date_day (start_date);
- end_year = g_date_year (end_date);
- end_month = g_date_month (end_date) - 1;
- end_day = g_date_day (end_date);
-
+
+ start_year = g_date_get_year (start_date);
+ start_month = g_date_get_month (start_date) - 1;
+ start_day = g_date_get_day (start_date);
+ end_year = g_date_get_year (end_date);
+ end_month = g_date_get_month (end_date) - 1;
+ end_day = g_date_get_day (end_date);
+
need_update = e_calendar_item_ensure_days_visible (calitem,
start_year,
start_month,