\section{calendar\-\_\-example\-\_\-06.\-c}

\begin{DoxyCodeInclude}

\textcolor{preprocessor}{#include <Elementary.h>}

\textcolor{preprocessor}{#define SECS\_DAY 86400}
\textcolor{preprocessor}{}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_btn\_clear\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *btn, \textcolor{keywordtype}{void} *ev)
\{
   Evas\_Object *cal = data;
   elm_calendar_marks_clear(cal);
   elm_calendar_marks_draw(cal);
\}

EAPI\_MAIN \textcolor{keywordtype}{int}
elm\_main(\textcolor{keywordtype}{int} argc, \textcolor{keywordtype}{char} **argv)
\{
   Evas\_Object *win, *bt, *bx, *cal;
   Elm\_Calendar\_Mark *mark;
   \textcolor{keyword}{struct }tm selected\_time;
   time\_t current\_time;
   \textcolor{keyword}{struct }tm sunday = \{ 0, 0, 12, 7, 0, 0, 0, 0, -1, 0, NULL \};
   \textcolor{comment}{/* tm \{sec, min, hour, mday, mon, year, wday, yday, isdst \} */}
   \textcolor{comment}{/* weekdays since Sunday, range 0 to 6 */}
   \textcolor{keyword}{struct }tm christmas;
   christmas.tm\_mday = 25;
   \textcolor{comment}{/* months since Jan, in the range 0 to 11 */}
   christmas.tm\_mon = 11;

   win = elm_win_util_standard_add(\textcolor{stringliteral}{"calendar"}, \textcolor{stringliteral}{"Calendar Marks Example"});
   elm_win_autodel_set(win, EINA\_TRUE);
   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);

   bx = elm_box_add(win);
   evas\_object\_size\_hint\_weight\_set(bx, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   elm_win_resize_object_add(win, bx);
   evas\_object\_show(bx);

   cal = elm_calendar_add(win);
   evas\_object\_size\_hint\_weight\_set(cal, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(cal, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm_box_pack_end(bx, cal);
   evas\_object\_show(cal);

   \textcolor{comment}{/* check today - we'll remove it later */}
   current\_time = time(NULL);
   localtime\_r(&current\_time, &selected\_time);
   mark = elm_calendar_mark_add(cal, \textcolor{stringliteral}{"checked"}, &selected\_time,
                                ELM\_CALENDAR\_UNIQUE);

   \textcolor{comment}{/* check tomorrow */}
   current\_time = time(NULL) + 1 * SECS\_DAY;
   localtime\_r(&current\_time, &selected\_time);
   elm_calendar_mark_add(cal, \textcolor{stringliteral}{"checked"}, &selected\_time, ELM\_CALENDAR\_UNIQUE);

   \textcolor{comment}{/* mark christmas as holiday */}
   elm_calendar_mark_add(cal, \textcolor{stringliteral}{"holiday"}, &christmas, ELM\_CALENDAR\_ANNUALLY);

   \textcolor{comment}{/* mark Sundays as holidays */}
   elm_calendar_mark_add(cal, \textcolor{stringliteral}{"holiday"}, &sunday, ELM\_CALENDAR\_WEEKLY);

   \textcolor{comment}{/* ok, let's remove today's check */}
   elm_calendar_mark_del(mark);

   elm_calendar_marks_draw(cal);

   bt = elm_button_add(win);
   evas\_object\_size\_hint\_weight\_set(bt, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(bt, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm\_object\_text\_set(bt, \textcolor{stringliteral}{"Clear marks"});
   evas\_object\_smart\_callback\_add(bt, \textcolor{stringliteral}{"clicked"}, \_btn\_clear\_cb, cal);
   elm_box_pack_end(bx, bt);
   evas\_object\_show(bt);

   evas\_object\_show(win);

   elm_run();
   elm_shutdown();

   \textcolor{keywordflow}{return} 0;
\}
ELM_MAIN()
\end{DoxyCodeInclude}
 