This example shows the difference between calling \mbox{\hyperlink{group__Ecore__Time__Group_ga98f2439b5d3e7114a75bfe2f0c22c4e9}{ecore\+\_\+time\+\_\+get()}}, \mbox{\hyperlink{group__Ecore__Time__Group_gab53d952cc4c2f3ed032d535b307c43bd}{ecore\+\_\+loop\+\_\+time\+\_\+get()}} and \mbox{\hyperlink{group__Ecore__Time__Group_ga0b8030aa39eb3701b6b30816ee9c45df}{ecore\+\_\+time\+\_\+unix\+\_\+get()}}.

It initializes ecore, then sets a timer with a callback that, when called, will retrieve the system time using these 3 different functions. After displaying the time, it sleeps for 1 second, then call display the time again using the 3 functions.

Since everything occurs inside the same main loop iteration, the internal ecore time variable will not be updated, and calling \mbox{\hyperlink{group__Ecore__Time__Group_gab53d952cc4c2f3ed032d535b307c43bd}{ecore\+\_\+loop\+\_\+time\+\_\+get()}} before and after the sleep() call will return the same result.

The two other functions will return a difference of 1 second, as expected. But \mbox{\hyperlink{group__Ecore__Time__Group_ga0b8030aa39eb3701b6b30816ee9c45df}{ecore\+\_\+time\+\_\+unix\+\_\+get()}} returns the number of seconds since 00\+:00\+:00 1st January 1970, while \mbox{\hyperlink{group__Ecore__Time__Group_ga98f2439b5d3e7114a75bfe2f0c22c4e9}{ecore\+\_\+time\+\_\+get()}} will return the time since a unspecified point, but that never goes back in time, even when the timezone of the machine changes.

\begin{DoxyNote}{Note}
The usage of \mbox{\hyperlink{group__Ecore__Time__Group_gab53d952cc4c2f3ed032d535b307c43bd}{ecore\+\_\+loop\+\_\+time\+\_\+get()}} should be preferred against the two other functions, for most time calculations, since it won\textquotesingle{}t produce a system call to get the current time. Use \mbox{\hyperlink{group__Ecore__Time__Group_ga0b8030aa39eb3701b6b30816ee9c45df}{ecore\+\_\+time\+\_\+unix\+\_\+get()}} when you need to know the current time and date, and \mbox{\hyperlink{group__Ecore__Time__Group_ga98f2439b5d3e7114a75bfe2f0c22c4e9}{ecore\+\_\+time\+\_\+get()}} when you need a monotonic and more precise time than \mbox{\hyperlink{group__Ecore__Time__Group_gab53d952cc4c2f3ed032d535b307c43bd}{ecore\+\_\+loop\+\_\+time\+\_\+get()}}.
\end{DoxyNote}

\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{comment}{//Compile\ with:}}
\DoxyCodeLine{\textcolor{comment}{//\ gcc\ -\/o\ ecore\_time\_functions\_example\ ecore\_time\_functions\_example.c\ `pkg-\/config\ -\/-\/libs\ -\/-\/cflags\ ecore`}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <Ecore.h>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <unistd.h>}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}}
\DoxyCodeLine{\_timer\_cb(\textcolor{keywordtype}{void}\ *data\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}ecore\ time:\ \%0.3f\(\backslash\)n"{}},\ \mbox{\hyperlink{group__Ecore__Time__Group_ga98f2439b5d3e7114a75bfe2f0c22c4e9}{ecore\_time\_get}}());}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}loop\ time:\ \%0.3f\(\backslash\)n"{}},\ \mbox{\hyperlink{group__Ecore__Time__Group_gab53d952cc4c2f3ed032d535b307c43bd}{ecore\_loop\_time\_get}}());}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}unix\ time:\ \%0.3f\(\backslash\)n"{}},\ \mbox{\hyperlink{group__Ecore__Time__Group_ga0b8030aa39eb3701b6b30816ee9c45df}{ecore\_time\_unix\_get}}());}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}\(\backslash\)nSleep\ for\ 1\ second...\(\backslash\)n\(\backslash\)n"{}});}
\DoxyCodeLine{\ \ \ sleep(1);}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}ecore\ time:\ \%0.3f\(\backslash\)n"{}},\ \mbox{\hyperlink{group__Ecore__Time__Group_ga98f2439b5d3e7114a75bfe2f0c22c4e9}{ecore\_time\_get}}());}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}loop\ time:\ \%0.3f\(\backslash\)n"{}},\ \mbox{\hyperlink{group__Ecore__Time__Group_gab53d952cc4c2f3ed032d535b307c43bd}{ecore\_loop\_time\_get}}());}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}unix\ time:\ \%0.3f\(\backslash\)n"{}},\ \mbox{\hyperlink{group__Ecore__Time__Group_ga0b8030aa39eb3701b6b30816ee9c45df}{ecore\_time\_unix\_get}}());}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Main__Loop__Group_ga95cf8e97dff0716433c2c5474d606a98}{ecore\_main\_loop\_quit}}();}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE}};}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{int}}
\DoxyCodeLine{main(\textcolor{keywordtype}{void})}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!\mbox{\hyperlink{group__Ecore__Init__Group_ga77757609684a2c922dc5ec398274751b}{ecore\_init}}())}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}ERROR:\ Cannot\ init\ Ecore!\(\backslash\)n"{}});}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Timer__Group_ga926423e464d7ef71105dd822d90e1187}{ecore\_timer\_add}}(0.1,\ \_timer\_cb,\ NULL);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Main__Loop__Group_gaf103b9f668bb3e4fed12e52c6180132d}{ecore\_main\_loop\_begin}}();}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Init__Group_ga768298b932f18d7e7593a447493e5cde}{ecore\_shutdown}}();}
\DoxyCodeLine{\}}
\DoxyCodeLine{}

\end{DoxyCodeInclude}
 