2008-09-04 Alejandro Pinheiro <apinheiro@igalia.com>
[hildon] / src / hildon-date-selector.c
1 /*
2  * This file is a part of hildon
3  *
4  * Copyright (C) 2005, 2008 Nokia Corporation.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version. or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free
18  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */
20
21 /**
22  * SECTION:hildon-date-selector
23  * @short_description: A widget to select the current date.
24  *
25  * HildonDateSelector is a date widget, equivalent to hildon-calendar, but with a multi-column
26  * approach
27  *
28  */
29
30 #define _GNU_SOURCE     /* needed for GNU nl_langinfo_l */
31 #define __USE_GNU       /* needed for locale */
32
33 #include <locale.h>
34
35 #ifdef HAVE_SYS_TIME_H
36 #include <sys/time.h>
37 #endif
38
39 #include <string.h>
40 #include <stdlib.h>
41
42 #include <libintl.h>
43 #include <time.h>
44 #include <langinfo.h>
45
46 #include "hildon-date-selector.h"
47
48 #define HILDON_DATE_SELECTOR_GET_PRIVATE(obj)                           \
49   (G_TYPE_INSTANCE_GET_PRIVATE ((obj), HILDON_TYPE_DATE_SELECTOR, HildonDateSelectorPrivate))
50
51 G_DEFINE_TYPE (HildonDateSelector, hildon_date_selector, HILDON_TYPE_TOUCH_SELECTOR)
52
53 #define INIT_YEAR 100
54 #define LAST_YEAR 50    /* since current year */
55
56 #define _(String) dgettext("hildon-libs", String)
57
58 /* #define _(String) "%A %e. %B %Y"  debug purposes */
59
60 enum
61 {
62   COLUMN_STRING,
63   COLUMN_INT,
64   N_COLUMNS
65 };
66
67 enum
68 {
69   DAY,
70   MONTH,
71   YEAR
72 };
73
74 struct _HildonDateSelectorPrivate
75 {
76   GtkTreeModel *year_model;
77   GtkTreeModel *month_model;
78   GtkTreeModel *day_model;
79
80   GSList *column_order;
81   gint day_column;
82   gint month_column;
83   gint year_column;             /* it depends on the locale */
84
85   gchar *format;                /* day/month/year format, depends on locale */
86
87   gint creation_day;
88   gint creation_month;
89   gint creation_year;           /* date at creation time */
90 };
91
92 static void hildon_date_selector_finalize (GObject * object);
93
94 /* private functions */
95 static GtkTreeModel *_create_day_model (HildonDateSelector * selector);
96 static GtkTreeModel *_create_year_model (HildonDateSelector * selector);
97 static GtkTreeModel *_create_month_model (HildonDateSelector * selector);
98
99 static void _get_real_date (gint * year, gint * month, gint * day);
100 static void _locales_init (HildonDateSelectorPrivate * priv);
101
102 static void _manage_selector_change_cb (HildonTouchSelector * selector,
103                                         gint num_column, gpointer data);
104
105 static GtkTreeModel *_update_day_model (HildonDateSelector * selector);
106
107 static gint _month_days (gint month, gint year);
108 static void _init_column_order (HildonDateSelector * selector);
109
110 static gchar *_custom_print_func (HildonTouchSelector * selector);
111
112 /***************************************************************************/
113 /* The following date routines are taken from the lib_date package.  Keep
114  * them separate in case we want to update them if a newer lib_date comes
115  * out with fixes.  */
116
117 typedef unsigned int N_int;
118
119 typedef unsigned long N_long;
120
121 typedef signed long Z_long;
122
123 typedef enum
124 { false = FALSE, true = TRUE } boolean;
125
126 #define                                         and &&  /* logical (boolean) operators: lower case */
127
128 #define                                         or ||
129
130 static const N_int month_length[2][13] = {
131   {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
132   {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
133 };
134
135 static const N_int days_in_months[2][14] = {
136   {0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365},
137   {0, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366}
138 };
139
140 static Z_long _calc_days (N_int year, N_int mm, N_int dd);
141
142 static N_int _day_of_week (N_int year, N_int mm, N_int dd);
143
144 static boolean _leap (N_int year);
145
146
147 static boolean
148 _leap (N_int year)
149 {
150   return ((((year % 4) == 0) and ((year % 100) != 0)) or ((year % 400) == 0));
151 }
152
153 static N_int
154 _day_of_week (N_int year, N_int mm, N_int dd)
155 {
156   Z_long days;
157
158   days = _calc_days (year, mm, dd);
159   if (days > 0L) {
160     days--;
161     days %= 7L;
162     days++;
163   }
164   return ((N_int) days);
165 }
166
167 static Z_long
168 _year_to_days (N_int year)
169 {
170   return (year * 365L + (year / 4) - (year / 100) + (year / 400));
171 }
172
173 static Z_long
174 _calc_days (N_int year, N_int mm, N_int dd)
175 {
176   boolean lp;
177
178   if (year < 1)
179     return (0L);
180   if ((mm < 1) or (mm > 12))
181     return (0L);
182   if ((dd < 1) or (dd > month_length[(lp = _leap (year))][mm]))
183     return (0L);
184   return (_year_to_days (--year) + days_in_months[lp][mm] + dd);
185 }
186
187 static void
188 hildon_date_selector_class_init (HildonDateSelectorClass * class)
189 {
190   GObjectClass *gobject_class;
191   GtkObjectClass *object_class;
192   GtkWidgetClass *widget_class;
193   GtkContainerClass *container_class;
194
195   gobject_class = (GObjectClass *) class;
196   object_class = (GtkObjectClass *) class;
197   widget_class = (GtkWidgetClass *) class;
198   container_class = (GtkContainerClass *) class;
199
200   /* GObject */
201   gobject_class->finalize = hildon_date_selector_finalize;
202
203   /* GtkWidget */
204
205   /* GtkContainer */
206
207   /* signals */
208
209   g_type_class_add_private (object_class, sizeof (HildonDateSelectorPrivate));
210 }
211
212 static void
213 hildon_date_selector_init (HildonDateSelector * selector)
214 {
215   GSList *iter = NULL;
216   gint current_item = 0;
217
218   selector->priv = HILDON_DATE_SELECTOR_GET_PRIVATE (selector);
219
220   GTK_WIDGET_SET_FLAGS (GTK_WIDGET (selector), GTK_NO_WINDOW);
221   gtk_widget_set_redraw_on_allocate (GTK_WIDGET (selector), FALSE);
222
223   hildon_touch_selector_set_print_func (HILDON_TOUCH_SELECTOR (selector),
224                                         _custom_print_func);
225
226   _locales_init (selector->priv);
227
228   _init_column_order (selector);
229
230   _get_real_date (&selector->priv->creation_year,
231                   &selector->priv->creation_month, &selector->priv->creation_day);
232
233   selector->priv->year_model = _create_year_model (selector);
234   selector->priv->month_model = _create_month_model (selector);
235   selector->priv->day_model = _create_day_model (selector);
236
237   /* We add the columns: FIXME: check the locale order */
238   iter = selector->priv->column_order;
239   for (iter = selector->priv->column_order; iter; iter = g_slist_next (iter)) {
240     current_item = GPOINTER_TO_INT (iter->data);
241
242     switch (current_item) {
243     case DAY:
244       hildon_touch_selector_append_text_column (HILDON_TOUCH_SELECTOR (selector),
245                                                 selector->priv->day_model, TRUE);
246       break;
247     case MONTH:
248       hildon_touch_selector_append_text_column (HILDON_TOUCH_SELECTOR (selector),
249                                                 selector->priv->month_model, TRUE);
250       break;
251     case YEAR:
252       hildon_touch_selector_append_text_column (HILDON_TOUCH_SELECTOR (selector),
253                                                 selector->priv->year_model, TRUE);
254       break;
255     default:
256       g_error ("Current column order incorrect");
257       break;
258     }
259   }
260
261   g_signal_connect (G_OBJECT (selector),
262                     "changed", G_CALLBACK (_manage_selector_change_cb), NULL);
263
264   /* By default we should select the current day */
265   hildon_date_selector_select_current_date (selector, selector->priv->creation_year,
266                                             selector->priv->creation_month,
267                                             selector->priv->creation_day);
268 }
269
270 static void
271 hildon_date_selector_finalize (GObject * object)
272 {
273   HildonDateSelector *selector = NULL;
274
275   selector = HILDON_DATE_SELECTOR (object);
276
277   g_slist_free (selector->priv->column_order);
278
279   g_free (selector->priv);
280
281   (*G_OBJECT_CLASS (hildon_date_selector_parent_class)->finalize) (object);
282 }
283
284 /* ------------------------------ PRIVATE METHODS ---------------------------- */
285 static gchar *
286 _custom_print_func (HildonTouchSelector * touch_selector)
287 {
288   HildonDateSelector *selector = NULL;
289   gchar *result = NULL;
290   guint year, month, day;
291   gint day_of_week = 0;
292   static gchar string[255];
293   struct tm tm = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
294
295   selector = HILDON_DATE_SELECTOR (touch_selector);
296
297   hildon_date_selector_get_date (selector, &year, &month, &day);
298   day_of_week = _day_of_week (year, month + 1, day) % 7;
299
300   tm.tm_mday = day;
301   tm.tm_mon = month;
302   tm.tm_year = year - 1900;
303   tm.tm_wday = day_of_week;
304
305   strftime (string, 255, _("wdgt_va_date_long"), &tm);
306
307   result = g_strdup (string);
308
309   return result;
310 }
311
312 /* This was copied from hildon-calendar */
313 static void
314 _locales_init (HildonDateSelectorPrivate * priv)
315 {
316   /* Hildon: This is not exactly portable, see
317    * http://bugzilla.gnome.org/show_bug.cgi?id=343415
318    * The labels need to be instance variables as the startup wizard changes
319    * locale on runtime.
320    */
321   locale_t l;
322
323   l = newlocale (LC_TIME_MASK, setlocale (LC_MESSAGES, NULL), NULL);
324
325   priv->format = g_locale_to_utf8 (nl_langinfo_l (D_FMT, l),
326                                    -1, NULL, NULL, NULL);
327
328   freelocale (l);
329 }
330
331 static void
332 _init_column_order (HildonDateSelector * selector)
333 {
334   gchar *current_order[3] = { NULL, NULL, NULL };
335   gchar *day_pos = NULL;
336   gchar *month_pos = NULL;
337   gchar *year_pos = NULL;
338   gint i, c;
339   gchar *aux = NULL;
340
341   g_debug ("Current format: %s", selector->priv->format);
342
343   /* search each token on the format */
344   day_pos = g_strrstr (selector->priv->format, "%d");
345
346   month_pos = g_strrstr (selector->priv->format, "%m");
347   year_pos = g_strrstr (selector->priv->format, "%y");
348   if (year_pos == NULL) {
349     year_pos = g_strrstr (selector->priv->format, "%Y");
350   }
351
352
353   if ((day_pos == NULL) || (month_pos == NULL) || (year_pos == NULL)) {
354     g_error ("Wrong date format");      /* so default values */
355
356     selector->priv->day_column = 0;
357     selector->priv->month_column = 1;
358     selector->priv->year_column = 2;
359     selector->priv->column_order = g_slist_append (NULL, GINT_TO_POINTER (DAY));
360     selector->priv->column_order =
361       g_slist_append (selector->priv->column_order, GINT_TO_POINTER (MONTH));
362     selector->priv->column_order =
363       g_slist_append (selector->priv->column_order, GINT_TO_POINTER (YEAR));
364   }
365
366   /* sort current_order with this values (bubble sort) */
367   current_order[0] = day_pos;
368   current_order[1] = month_pos;
369   current_order[2] = year_pos;
370
371   for (c = 1; c <= 2; c++) {
372     for (i = 0; i < 3 - c; i++) {
373       if (current_order[i] > current_order[i + 1]) {
374         aux = current_order[i];
375         current_order[i] = current_order[i + 1];
376         current_order[i + 1] = aux;
377       }
378     }
379   }
380
381   /* fill the column positions */
382   selector->priv->column_order = NULL;
383   c = 0;
384   for (i = 0; i < 3; i++) {
385     if (current_order[i] == day_pos) {
386       selector->priv->column_order =
387         g_slist_append (selector->priv->column_order, GINT_TO_POINTER (DAY));
388       selector->priv->day_column = c++;
389     }
390     if (current_order[i] == month_pos) {
391       selector->priv->column_order =
392         g_slist_append (selector->priv->column_order, GINT_TO_POINTER (MONTH));
393       selector->priv->month_column = c++;
394     }
395     if (current_order[i] == year_pos) {
396       selector->priv->column_order =
397         g_slist_append (selector->priv->column_order, GINT_TO_POINTER (YEAR));
398       selector->priv->year_column = c++;
399     }
400   }
401 }
402
403
404 static GtkTreeModel *
405 _create_day_model (HildonDateSelector * selector)
406 {
407   GtkListStore *store_days = NULL;
408   gint i = 0;
409   gchar label[255];
410   struct tm tm = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
411   GtkTreeIter iter;
412
413   store_days = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
414   for (i = 1; i < 32; i++) {
415     tm.tm_mday = i;
416     strftime (label, 255, _("wdgt_va_day_numeric"), &tm);
417
418     gtk_list_store_append (store_days, &iter);
419     gtk_list_store_set (store_days, &iter,
420                         COLUMN_STRING, label, COLUMN_INT, i, -1);
421   }
422
423   return GTK_TREE_MODEL (store_days);
424 }
425
426 static GtkTreeModel *
427 _create_year_model (HildonDateSelector * selector)
428 {
429   GtkListStore *store_years = NULL;
430   gint real_year = 0;
431   gint i = 0;
432   static gchar label[255];
433   struct tm tm = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
434   GtkTreeIter iter;
435
436   real_year = selector->priv->creation_year;
437
438   store_years = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
439   for (i = real_year - INIT_YEAR; i < real_year + LAST_YEAR; i++) {
440     tm.tm_year = i - 1900;
441     strftime (label, 255, _("wdgt_va_year"), &tm);
442
443     gtk_list_store_append (store_years, &iter);
444     gtk_list_store_set (store_years, &iter,
445                         COLUMN_STRING, label, COLUMN_INT, i, -1);
446   }
447
448   return GTK_TREE_MODEL (store_years);
449 }
450
451 static GtkTreeModel *
452 _create_month_model (HildonDateSelector * selector)
453 {
454   GtkTreeIter iter;
455   gint i = 0;
456   GtkListStore *store_months = NULL;
457   static gchar label[255];
458   struct tm tm = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
459
460   store_months = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
461   for (i = 0; i < 12; i++) {
462     tm.tm_mon = i;
463     strftime (label, 255, _("wdgt_va_month"), &tm);
464
465     gtk_list_store_append (store_months, &iter);
466     gtk_list_store_set (store_months, &iter, COLUMN_STRING, label,
467                         COLUMN_INT, i,
468                         -1);
469   }
470
471   return GTK_TREE_MODEL (store_months);
472 }
473
474 static GtkTreeModel *
475 _update_day_model (HildonDateSelector * selector)
476 {
477   GtkListStore *store_days = NULL;
478   gint i = 0;
479   GtkTreeIter iter;
480   static gchar label[255];
481   struct tm tm = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
482   guint current_day = 0;
483   guint current_year = 0;
484   guint current_month = 0;
485   guint num_days = 31;
486
487   hildon_date_selector_get_date (selector, NULL, NULL, &current_day);
488
489   hildon_touch_selector_get_selected (HILDON_TOUCH_SELECTOR (selector),
490                                       selector->priv->month_column, &iter);
491   gtk_tree_model_get (selector->priv->month_model,
492                       &iter, COLUMN_INT, &current_month, -1);
493
494   hildon_touch_selector_get_selected (HILDON_TOUCH_SELECTOR (selector),
495                                       selector->priv->year_column, &iter);
496   gtk_tree_model_get (selector->priv->year_model,
497                       &iter, COLUMN_INT, &current_year, -1);
498
499   num_days = _month_days (current_month, current_year);
500
501   store_days = GTK_LIST_STORE (selector->priv->day_model);
502   gtk_list_store_clear (store_days);
503
504   for (i = 1; i <= num_days; i++) {
505     tm.tm_mday = i;
506     strftime (label, 255, _("wdgt_va_day_numeric"), &tm);
507
508     gtk_list_store_append (store_days, &iter);
509     gtk_list_store_set (store_days, &iter,
510                         COLUMN_STRING, label, COLUMN_INT, i, -1);
511   }
512
513   /* now we select a day */
514   if (current_day >= num_days) {
515     current_day = num_days;
516   }
517
518   hildon_date_selector_select_day (selector, current_day);
519
520   return GTK_TREE_MODEL (store_days);
521 }
522
523
524 static void
525 _get_real_date (gint * year, gint * month, gint * day)
526 {
527   time_t secs;
528   struct tm *tm = NULL;
529
530   secs = time (NULL);
531   tm = localtime (&secs);
532
533   if (year != NULL) {
534     *year = 1900 + tm->tm_year;
535   }
536
537   if (month != NULL) {
538     *month = tm->tm_mon;
539   }
540
541   if (day != NULL) {
542     *day = tm->tm_mday;
543   }
544 }
545
546
547 static void
548 _manage_selector_change_cb (HildonTouchSelector * touch_selector,
549                             gint num_column, gpointer data)
550 {
551   HildonDateSelector *selector = NULL;
552
553   g_return_if_fail (HILDON_IS_DATE_SELECTOR (touch_selector));
554   selector = HILDON_DATE_SELECTOR (touch_selector);
555
556   if ((num_column == selector->priv->month_column) ||
557       (num_column == selector->priv->year_column)) /* it is required to check that with
558                                                     * the years too,remember: leap years
559                                                     */
560   {
561     _update_day_model (selector);
562   }
563 }
564
565 static gint
566 _month_days (gint month, gint year)
567 {
568   gint month_days[2][12] = {
569     {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
570     {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
571   };
572
573   g_return_val_if_fail (month >= 0 && month <= 12, -1);
574
575   return month_days[_leap (year)][month];
576 }
577
578
579 /* ------------------------------ PUBLIC METHODS ---------------------------- */
580
581 /**
582  * hildon_date_selector_new:
583  *
584  * Creates a new #HildonDateSelector
585  *
586  * Returns: a new #HildonDateSelector
587  **/
588 GtkWidget *
589 hildon_date_selector_new ()
590 {
591   return g_object_new (HILDON_TYPE_DATE_SELECTOR, NULL);
592 }
593
594
595 /**
596  * hildon_date_selector_select_date:
597  * @selector: the #HildonDateSelector
598  * @year:  the current year
599  * @month: the current month (0-11)
600  * @day:   the current day (1-31, 1-30, 1-29, 1-28) depends on the month
601  *
602  * Sets the current active date on the #HildonDateSelector widget
603  *
604  **/
605 gboolean
606 hildon_date_selector_select_current_date (HildonDateSelector * selector,
607                                           guint year, guint month, guint day)
608 {
609   GtkTreeIter iter;
610   gint min_year = 0;
611   gint max_year = 0;
612   gint num_days = 0;
613
614   min_year = selector->priv->creation_year - INIT_YEAR;
615   max_year = selector->priv->creation_year + LAST_YEAR;
616
617   g_return_val_if_fail (year > min_year && year < max_year, FALSE);
618   g_return_val_if_fail (month >= 0 && month < 12, FALSE);
619
620   num_days = _month_days (month, year);
621   g_return_val_if_fail (day > 0 && day <= num_days, FALSE);
622
623
624   gtk_tree_model_iter_nth_child (selector->priv->year_model, &iter, NULL,
625                                  year - selector->priv->creation_year +
626                                  INIT_YEAR);
627   hildon_touch_selector_select_iter (HILDON_TOUCH_SELECTOR (selector),
628                                      selector->priv->year_column, &iter,
629                                      FALSE);
630
631   gtk_tree_model_iter_nth_child (selector->priv->month_model, &iter, NULL,
632                                  month);
633   hildon_touch_selector_select_iter (HILDON_TOUCH_SELECTOR (selector),
634                                      selector->priv->month_column, &iter,
635                                      FALSE);
636
637   gtk_tree_model_iter_nth_child (selector->priv->day_model, &iter, NULL,
638                                  day - 1);
639   hildon_touch_selector_select_iter (HILDON_TOUCH_SELECTOR (selector),
640                                      selector->priv->day_column, &iter,
641                                      FALSE);
642
643   return TRUE;
644 }
645
646
647 /**
648  * hildon_date_selector_get_date:
649  * @selector: the #HildonDateSelector
650  * @year:  to set the current year
651  * @month: to set the current month (0-11)
652  * @day:   to the current day (1-31, 1-30, 1-29, 1-28) depends on the month
653  *
654  * Gets the current active date on the #HildonDateSelector widget
655  *
656  *
657  **/
658 void
659 hildon_date_selector_get_date (HildonDateSelector * selector,
660                                guint * year, guint * month, guint * day)
661 {
662   GtkTreeIter iter;
663
664   if (year != NULL) {
665     hildon_touch_selector_get_selected (HILDON_TOUCH_SELECTOR (selector),
666                                         selector->priv->year_column, &iter);
667     gtk_tree_model_get (selector->priv->year_model,
668                         &iter, COLUMN_INT, year, -1);
669   }
670
671   if (month != NULL) {
672     hildon_touch_selector_get_selected (HILDON_TOUCH_SELECTOR (selector),
673                                         selector->priv->month_column, &iter);
674     gtk_tree_model_get (selector->priv->month_model,
675                         &iter, COLUMN_INT, month, -1);
676   }
677
678
679   if (day != NULL) {
680     if (hildon_touch_selector_get_selected (HILDON_TOUCH_SELECTOR (selector),
681                                             selector->priv->day_column, &iter))
682     {
683       gtk_tree_model_get (selector->priv->day_model,
684                           &iter, COLUMN_INT, day, -1);
685     }
686 /*       *day = *day - 1;  */
687   }
688
689 }
690
691
692 /**
693  * hildon_date_selector_select_month:
694  * @selector: the #HildonDateSelector
695  * @month: the current month (0-11)
696  * @year:  the current year
697  *
698  * Modify the current month and year on the current active date
699  *
700  * Utility function, too keep this API more similar to the previously existing
701  * hildon-calendar widget.
702  *
703  *
704  **/
705 gboolean hildon_date_selector_select_month (HildonDateSelector *selector,
706                                             guint month, guint year)
707 {
708   guint day = 0;
709
710   hildon_date_selector_get_date (selector, NULL, NULL, &day);
711
712   return hildon_date_selector_select_current_date (selector, year, month, day);
713 }
714
715 /**
716  * hildon_date_selector_select_day:
717  * @selector: the #HildonDateSelector
718  * @day:   the current day (1-31, 1-30, 1-29, 1-28) depends on the month
719  *
720  * Modify the current day on the current active date
721  *
722  * Utility function, too keep this API more similar to the previously existing
723  * hildon-calendar widget.
724  *
725  *
726  **/
727 void
728 hildon_date_selector_select_day (HildonDateSelector *selector, guint day)
729 {
730   guint month = 0;
731   guint year = 0;
732
733   hildon_date_selector_get_date (selector, &year, &month, NULL);
734
735   hildon_date_selector_select_current_date (selector, year, month, day);
736 }