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

\begin{DoxyCodeInclude}

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

\textcolor{preprocessor}{#define SECS\_DAY 86400}

\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();

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