[gnome-calendar/wip/pandusonu/week-view: 13/31] week-header: corrected the date of start of the week
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar/wip/pandusonu/week-view: 13/31] week-header: corrected the date of start of the week
- Date: Wed, 2 Nov 2016 16:08:13 +0000 (UTC)
commit e91b485023cfade2abe5f9b86097efcdd3f2ff36
Author: pandusonu2 <pandu sonu yahoo com>
Date: Fri Jun 17 01:14:28 2016 +0530
week-header: corrected the date of start of the week
The active date is taken as the start of the week
Added a function to get the correct date at start of the week.
src/views/gcal-week-header.c | 26 ++++++++++++++++++++++++--
1 files changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/src/views/gcal-week-header.c b/src/views/gcal-week-header.c
index 3490d7a..93a5d31 100644
--- a/src/views/gcal-week-header.c
+++ b/src/views/gcal-week-header.c
@@ -49,6 +49,8 @@ struct _GcalWeekHeader
icaltimetype *current_date;
};
+static GDateTime* get_start_of_week (GcalWeekHeader *self);
+
static void update_headers (GcalWeekHeader *self);
static void gcal_week_header_finalize (GObject *object);
@@ -75,6 +77,26 @@ enum
G_DEFINE_TYPE (GcalWeekHeader, gcal_week_header, GTK_TYPE_SCROLLED_WINDOW);
+static GDateTime*
+get_start_of_week (GcalWeekHeader *self)
+{
+ icaltimetype *new_date;
+
+ g_return_val_if_fail (GCAL_IS_WEEK_HEADER (self), NULL);
+ new_date = g_new0 (icaltimetype, 1);
+ *new_date = icaltime_from_day_of_year (icaltime_start_doy_week (*(self->active_date),
+ self->first_weekday + 1),
+ self->active_date->year);
+ new_date->is_date = 0;
+ new_date->hour = 0;
+ new_date->minute = 0;
+ new_date->second = 0;
+
+ *new_date = icaltime_set_timezone (new_date, self->active_date->zone);
+
+ return icaltime_to_datetime (new_date);
+}
+
static void
update_headers (GcalWeekHeader *self)
{
@@ -84,7 +106,7 @@ update_headers (GcalWeekHeader *self)
if(!self->active_date)
return;
- week_start = icaltime_to_datetime (self->active_date);
+ week_start = get_start_of_week (self);
week_end = g_date_time_add_days (week_start, 6);
if (g_date_time_get_month (week_start) == g_date_time_get_month (week_end))
@@ -226,7 +248,7 @@ gcal_week_header_draw (GcalWeekHeader *self,
pango_font_description_set_weight (bold_font, PANGO_WEIGHT_SEMIBOLD);
pango_layout_set_font_description (layout, bold_font);
- week_start = icaltime_to_datetime (self->active_date);
+ week_start = get_start_of_week (self);
week_end = g_date_time_add_days (week_start, 6);
current_cell = icaltime_day_of_week (*(self->active_date)) - 1;
current_cell = (7 + current_cell - self->first_weekday) % 7;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]