This example shows the difference between calling \hyperlink{group__Ecore__Time__Group_ga98f2439b5d3e7114a75bfe2f0c22c4e9}{ecore\+\_\+time\+\_\+get()}, \hyperlink{group__Ecore__Time__Group_gab53d952cc4c2f3ed032d535b307c43bd}{ecore\+\_\+loop\+\_\+time\+\_\+get()} and \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 \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 \hyperlink{group__Ecore__Time__Group_ga0b8030aa39eb3701b6b30816ee9c45df}{ecore\+\_\+time\+\_\+unix\+\_\+get()} returns the number of seconds since 00\+:00\+:00 1st January 1970, while \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 \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't produce a system call to get the current time. Use \hyperlink{group__Ecore__Time__Group_ga0b8030aa39eb3701b6b30816ee9c45df}{ecore\+\_\+time\+\_\+unix\+\_\+get()} when you need to know the current time and date, and \hyperlink{group__Ecore__Time__Group_ga98f2439b5d3e7114a75bfe2f0c22c4e9}{ecore\+\_\+time\+\_\+get()} when you need a monotonic and more precise time than \hyperlink{group__Ecore__Time__Group_gab53d952cc4c2f3ed032d535b307c43bd}{ecore\+\_\+loop\+\_\+time\+\_\+get()}.
\end{DoxyNote}

\begin{DoxyCodeInclude}
\textcolor{comment}{//Compile with:}
\textcolor{comment}{// gcc -o ecore\_time\_functions\_example ecore\_time\_functions\_example.c `pkg-config --libs --cflags ecore`}

\textcolor{preprocessor}{#include <Ecore.h>}
\textcolor{preprocessor}{#include <unistd.h>}

\textcolor{keyword}{static} \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}
\_timer\_cb(\textcolor{keywordtype}{void} *data EINA\_UNUSED)
\{
   printf(\textcolor{stringliteral}{"ecore time: %0.3f\(\backslash\)n"}, \hyperlink{group__Ecore__Time__Group_ga98f2439b5d3e7114a75bfe2f0c22c4e9}{ecore\_time\_get}());
   printf(\textcolor{stringliteral}{"loop time: %0.3f\(\backslash\)n"}, \hyperlink{group__Ecore__Time__Group_gab53d952cc4c2f3ed032d535b307c43bd}{ecore\_loop\_time\_get}());
   printf(\textcolor{stringliteral}{"unix time: %0.3f\(\backslash\)n"}, \hyperlink{group__Ecore__Time__Group_ga0b8030aa39eb3701b6b30816ee9c45df}{ecore\_time\_unix\_get}());
   printf(\textcolor{stringliteral}{"\(\backslash\)nSleep for 1 second...\(\backslash\)n\(\backslash\)n"});
   sleep(1);
   printf(\textcolor{stringliteral}{"ecore time: %0.3f\(\backslash\)n"}, \hyperlink{group__Ecore__Time__Group_ga98f2439b5d3e7114a75bfe2f0c22c4e9}{ecore\_time\_get}());
   printf(\textcolor{stringliteral}{"loop time: %0.3f\(\backslash\)n"}, \hyperlink{group__Ecore__Time__Group_gab53d952cc4c2f3ed032d535b307c43bd}{ecore\_loop\_time\_get}());
   printf(\textcolor{stringliteral}{"unix time: %0.3f\(\backslash\)n"}, \hyperlink{group__Ecore__Time__Group_ga0b8030aa39eb3701b6b30816ee9c45df}{ecore\_time\_unix\_get}());

   \hyperlink{group__Ecore__Main__Loop__Group_ga95cf8e97dff0716433c2c5474d606a98}{ecore\_main\_loop\_quit}();

   \textcolor{keywordflow}{return} \hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE};
\}

\textcolor{keywordtype}{int}
main(\textcolor{keywordtype}{void})
\{
   \textcolor{keywordflow}{if} (!\hyperlink{group__Ecore__Init__Group_ga77757609684a2c922dc5ec398274751b}{ecore\_init}())
     \{
        printf(\textcolor{stringliteral}{"ERROR: Cannot init Ecore!\(\backslash\)n"});
        \textcolor{keywordflow}{return} -1;
     \}

   ecore\_timer\_add(0.1, \_timer\_cb, NULL);
   \hyperlink{group__Ecore__Main__Loop__Group_gaf103b9f668bb3e4fed12e52c6180132d}{ecore\_main\_loop\_begin}();
   \hyperlink{group__Ecore__Init__Group_ga768298b932f18d7e7593a447493e5cde}{ecore\_shutdown}();
\}

\end{DoxyCodeInclude}
 