summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMariusz Bialonczyk <manio@skyboo.net>2013-09-30 11:39:34 +0100
committerStefan Schmidt <s.schmidt@samsung.com>2013-09-30 13:33:44 +0100
commit144734972ad848b3e3516ddf47233b741b42dc16 (patch)
tree9bec2435510376751e57a44bfa80e8329833c46a
parentb216de22610fd8831f03fd9fd32b9f4ffdd20c30 (diff)
test_calendar: Fix number of seconds per day.
Previous seconds value for a day was 84600 (23:30) instead of 86400 (24:00). The commit fixes it using constants.
-rw-r--r--src/bin/test_calendar.c43
1 files changed, 17 insertions, 26 deletions
diff --git a/src/bin/test_calendar.c b/src/bin/test_calendar.c
index f3b7ee343..3bd82cf1a 100644
--- a/src/bin/test_calendar.c
+++ b/src/bin/test_calendar.c
@@ -21,6 +21,9 @@ enum _api_state
21}; 21};
22typedef enum _api_state api_state; 22typedef enum _api_state api_state;
23 23
24#define SEC_PER_DAY 24 * 60 * 60
25#define SEC_PER_YEAR 365 * SEC_PER_DAY
26
24static void 27static void
25set_api_state(api_data *api) 28set_api_state(api_data *api)
26{ 29{
@@ -34,9 +37,7 @@ set_api_state(api_data *api)
34 case STATE_MARK_MONTHLY: 37 case STATE_MARK_MONTHLY:
35 { 38 {
36 Evas_Object *cal = eina_list_nth(items, 0); 39 Evas_Object *cal = eina_list_nth(items, 0);
37 time_t sec_per_day = (60*60*24); 40 time_t the_time = (SEC_PER_YEAR * 41) + (SEC_PER_DAY * 9); /* Set date to DEC 31, 2010 */
38 time_t sec_per_year = sec_per_day * 365;
39 time_t the_time = (sec_per_year * 41) + (sec_per_day * 9); /* Set date to DEC 31, 2010 */
40 elm_calendar_min_max_year_set(cal, 2010, 2011); 41 elm_calendar_min_max_year_set(cal, 2010, 2011);
41 m = elm_calendar_mark_add(cal, "checked", gmtime(&the_time), ELM_CALENDAR_MONTHLY); 42 m = elm_calendar_mark_add(cal, "checked", gmtime(&the_time), ELM_CALENDAR_MONTHLY);
42 elm_calendar_selected_time_set(cal, gmtime(&the_time)); 43 elm_calendar_selected_time_set(cal, gmtime(&the_time));
@@ -45,9 +46,7 @@ set_api_state(api_data *api)
45 case STATE_MARK_WEEKLY: 46 case STATE_MARK_WEEKLY:
46 { 47 {
47 Evas_Object *cal = eina_list_nth(items, 0); 48 Evas_Object *cal = eina_list_nth(items, 0);
48 time_t sec_per_day = (60*60*24); 49 time_t the_time = (SEC_PER_YEAR * 41) + (SEC_PER_DAY * 4); /* Set date to DEC 26, 2010 */
49 time_t sec_per_year = sec_per_day * 365;
50 time_t the_time = (sec_per_year * 41) + (sec_per_day * 4); /* Set date to DEC 26, 2010 */
51 elm_calendar_mark_del(m); 50 elm_calendar_mark_del(m);
52 m = elm_calendar_mark_add(cal, "checked", gmtime(&the_time), ELM_CALENDAR_WEEKLY); 51 m = elm_calendar_mark_add(cal, "checked", gmtime(&the_time), ELM_CALENDAR_WEEKLY);
53 elm_calendar_selected_time_set(cal, gmtime(&the_time)); 52 elm_calendar_selected_time_set(cal, gmtime(&the_time));
@@ -56,9 +55,7 @@ set_api_state(api_data *api)
56 case STATE_SUNDAY_HIGHLIGHT: 55 case STATE_SUNDAY_HIGHLIGHT:
57 { 56 {
58 Evas_Object *cal = eina_list_nth(items, 0); 57 Evas_Object *cal = eina_list_nth(items, 0);
59 time_t sec_per_day = (60*60*24); 58 time_t the_time = (SEC_PER_YEAR * 41) + (SEC_PER_DAY * 3); /* Set date to DEC 25, 2010 */
60 time_t sec_per_year = sec_per_day * 365;
61 time_t the_time = (sec_per_year * 41) + (sec_per_day * 3); /* Set date to DEC 25, 2010 */
62 /* elm_calendar_mark_del(m); */ 59 /* elm_calendar_mark_del(m); */
63 m = elm_calendar_mark_add(cal, "holiday", gmtime(&the_time), ELM_CALENDAR_WEEKLY); 60 m = elm_calendar_mark_add(cal, "holiday", gmtime(&the_time), ELM_CALENDAR_WEEKLY);
64 elm_calendar_selected_time_set(cal, gmtime(&the_time)); 61 elm_calendar_selected_time_set(cal, gmtime(&the_time));
@@ -67,9 +64,7 @@ set_api_state(api_data *api)
67 case STATE_SELECT_DATE_DISABLED_WITH_MARKS: 64 case STATE_SELECT_DATE_DISABLED_WITH_MARKS:
68 { 65 {
69 Evas_Object *cal = eina_list_nth(items, 0); 66 Evas_Object *cal = eina_list_nth(items, 0);
70 time_t sec_per_day = (60*60*24); 67 time_t the_time = (SEC_PER_YEAR * 41) + (SEC_PER_DAY * 10); /* Set date to JAN 01, 2011 */
71 time_t sec_per_year = sec_per_day * 365;
72 time_t the_time = (sec_per_year * 41) + (sec_per_day * 10); /* Set date to JAN 01, 2011 */
73 elm_calendar_select_mode_set(cal, ELM_CALENDAR_SELECT_MODE_NONE); 68 elm_calendar_select_mode_set(cal, ELM_CALENDAR_SELECT_MODE_NONE);
74 elm_calendar_selected_time_set(cal, gmtime(&the_time)); 69 elm_calendar_selected_time_set(cal, gmtime(&the_time));
75 } 70 }
@@ -77,9 +72,7 @@ set_api_state(api_data *api)
77 case STATE_SELECT_DATE_DISABLED_NO_MARKS: 72 case STATE_SELECT_DATE_DISABLED_NO_MARKS:
78 { 73 {
79 Evas_Object *cal = eina_list_nth(items, 0); 74 Evas_Object *cal = eina_list_nth(items, 0);
80 time_t sec_per_day = (60*60*24); 75 time_t the_time = (SEC_PER_YEAR * 41) + (SEC_PER_DAY * 40); /* Set date to FEB 01, 2011 */
81 time_t sec_per_year = sec_per_day * 365;
82 time_t the_time = (sec_per_year * 41) + (sec_per_day * 40); /* Set date to FEB 01, 2011 */
83 elm_calendar_marks_clear(cal); 76 elm_calendar_marks_clear(cal);
84 elm_calendar_select_mode_set(cal, ELM_CALENDAR_SELECT_MODE_NONE); 77 elm_calendar_select_mode_set(cal, ELM_CALENDAR_SELECT_MODE_NONE);
85 elm_calendar_selected_time_set(cal, gmtime(&the_time)); 78 elm_calendar_selected_time_set(cal, gmtime(&the_time));
@@ -148,9 +141,7 @@ test_calendar(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_
148 evas_object_size_hint_weight_set(cal, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 141 evas_object_size_hint_weight_set(cal, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
149 elm_box_pack_end(bx, cal); 142 elm_box_pack_end(bx, cal);
150 143
151 time_t sec_per_day = (60*60*24); 144 time_t the_time = (SEC_PER_YEAR * 41) + (SEC_PER_DAY * 9); /* Set date to DEC 31, 2010 */
152 time_t sec_per_year = sec_per_day * 365;
153 time_t the_time = (sec_per_year * 41) + (sec_per_day * 9); /* Set date to DEC 31, 2010 */
154 elm_calendar_selected_time_set(cal, gmtime(&the_time)); 145 elm_calendar_selected_time_set(cal, gmtime(&the_time));
155 elm_calendar_min_max_year_set(cal, 2010, 2012); 146 elm_calendar_min_max_year_set(cal, 2010, 2012);
156 147
@@ -268,10 +259,10 @@ test_calendar2(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event
268 cal3 = elm_calendar_add(win); 259 cal3 = elm_calendar_add(win);
269 evas_object_size_hint_weight_set(cal3, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 260 evas_object_size_hint_weight_set(cal3, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
270 evas_object_size_hint_align_set(cal3, EVAS_HINT_FILL, EVAS_HINT_FILL); 261 evas_object_size_hint_align_set(cal3, EVAS_HINT_FILL, EVAS_HINT_FILL);
271 current_time = time(NULL) + 34 * 84600; 262 current_time = time(NULL) + 34 * SEC_PER_DAY;
272 localtime_r(&current_time, &selected_time); 263 localtime_r(&current_time, &selected_time);
273 elm_calendar_selected_time_set(cal3, &selected_time); 264 elm_calendar_selected_time_set(cal3, &selected_time);
274 current_time = time(NULL) + 1 * 84600; 265 current_time = time(NULL) + 1 * SEC_PER_DAY;
275 localtime_r(&current_time, &selected_time); 266 localtime_r(&current_time, &selected_time);
276 elm_calendar_mark_add(cal3, "checked", &selected_time, ELM_CALENDAR_UNIQUE); 267 elm_calendar_mark_add(cal3, "checked", &selected_time, ELM_CALENDAR_UNIQUE);
277 elm_calendar_marks_clear(cal3); 268 elm_calendar_marks_clear(cal3);
@@ -299,24 +290,24 @@ test_calendar2(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event
299 elm_calendar_format_function_set(cal, _format_month_year); 290 elm_calendar_format_function_set(cal, _format_month_year);
300 elm_calendar_min_max_year_set(cal, 2010, 2020); 291 elm_calendar_min_max_year_set(cal, 2010, 2020);
301 292
302 current_time = time(NULL) + 4 * 84600; 293 current_time = time(NULL) + 4 * SEC_PER_DAY;
303 localtime_r(&current_time, &selected_time); 294 localtime_r(&current_time, &selected_time);
304 elm_calendar_mark_add(cal, "holiday", &selected_time, ELM_CALENDAR_ANNUALLY); 295 elm_calendar_mark_add(cal, "holiday", &selected_time, ELM_CALENDAR_ANNUALLY);
305 296
306 current_time = time(NULL) + 1 * 84600; 297 current_time = time(NULL) + 1 * SEC_PER_DAY;
307 localtime_r(&current_time, &selected_time); 298 localtime_r(&current_time, &selected_time);
308 elm_calendar_mark_add(cal, "checked", &selected_time, ELM_CALENDAR_UNIQUE); 299 elm_calendar_mark_add(cal, "checked", &selected_time, ELM_CALENDAR_UNIQUE);
309 300
310 current_time = time(NULL) - 363 * 84600; 301 current_time = time(NULL) - 363 * SEC_PER_DAY;
311 localtime_r(&current_time, &selected_time); 302 localtime_r(&current_time, &selected_time);
312 elm_calendar_mark_add(cal, "checked", &selected_time, ELM_CALENDAR_MONTHLY); 303 elm_calendar_mark_add(cal, "checked", &selected_time, ELM_CALENDAR_MONTHLY);
313 304
314 current_time = time(NULL) - 5 * 84600; 305 current_time = time(NULL) - 5 * SEC_PER_DAY;
315 localtime_r(&current_time, &selected_time); 306 localtime_r(&current_time, &selected_time);
316 mark = elm_calendar_mark_add(cal, "holiday", &selected_time, 307 mark = elm_calendar_mark_add(cal, "holiday", &selected_time,
317 ELM_CALENDAR_WEEKLY); 308 ELM_CALENDAR_WEEKLY);
318 309
319 current_time = time(NULL) + 1 * 84600; 310 current_time = time(NULL) + 1 * SEC_PER_DAY;
320 localtime_r(&current_time, &selected_time); 311 localtime_r(&current_time, &selected_time);
321 elm_calendar_mark_add(cal, "holiday", &selected_time, ELM_CALENDAR_WEEKLY); 312 elm_calendar_mark_add(cal, "holiday", &selected_time, ELM_CALENDAR_WEEKLY);
322 313
@@ -357,7 +348,7 @@ test_calendar3(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event
357 elm_calendar_selectable_set(cal, 348 elm_calendar_selectable_set(cal,
358 (ELM_CALENDAR_SELECTABLE_YEAR 349 (ELM_CALENDAR_SELECTABLE_YEAR
359 | ELM_CALENDAR_SELECTABLE_MONTH)); 350 | ELM_CALENDAR_SELECTABLE_MONTH));
360 current_time = time(NULL) + 34 * 84600; 351 current_time = time(NULL) + 34 * SEC_PER_DAY;
361 localtime_r(&current_time, &selected_time); 352 localtime_r(&current_time, &selected_time);
362 evas_object_size_hint_weight_set(cal, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 353 evas_object_size_hint_weight_set(cal, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
363 elm_box_pack_end(bx, cal); 354 elm_box_pack_end(bx, cal);