This example shows the difference between calling \hyperlink{group__Ecore__Time__Group_ga43846b079394bb4d098abf5c16dfc544}{ecore\-\_\-time\-\_\-get()}, \hyperlink{group__Ecore__Time__Group_gadcbdc1aa699fbe4acd1b5427befd04d1}{ecore\-\_\-loop\-\_\-time\-\_\-get()} and \hyperlink{group__Ecore__Time__Group_ga4644b45bfca1495322913f9e529d82fc}{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_gadcbdc1aa699fbe4acd1b5427befd04d1}{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_ga4644b45bfca1495322913f9e529d82fc}{ecore\-\_\-time\-\_\-unix\-\_\-get()} returns the number of seconds since 00\-:00\-:00 1st January 1970, while \hyperlink{group__Ecore__Time__Group_ga43846b079394bb4d098abf5c16dfc544}{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_gadcbdc1aa699fbe4acd1b5427befd04d1}{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_ga4644b45bfca1495322913f9e529d82fc}{ecore\-\_\-time\-\_\-unix\-\_\-get()} when you need to know the current time and date, and \hyperlink{group__Ecore__Time__Group_ga43846b079394bb4d098abf5c16dfc544}{ecore\-\_\-time\-\_\-get()} when you need a monotonic and more precise time than \hyperlink{group__Ecore__Time__Group_gadcbdc1aa699fbe4acd1b5427befd04d1}{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_ga43846b079394bb4d098abf5c16dfc544}{ecore\_time\_get}());
   printf(\textcolor{stringliteral}{"loop time: %0.3f\(\backslash\)n"}, \hyperlink{group__Ecore__Time__Group_gadcbdc1aa699fbe4acd1b5427befd04d1}{ecore\_loop\_time\_get}());
   printf(\textcolor{stringliteral}{"unix time: %0.3f\(\backslash\)n"}, \hyperlink{group__Ecore__Time__Group_ga4644b45bfca1495322913f9e529d82fc}{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_ga43846b079394bb4d098abf5c16dfc544}{ecore\_time\_get}());
   printf(\textcolor{stringliteral}{"loop time: %0.3f\(\backslash\)n"}, \hyperlink{group__Ecore__Time__Group_gadcbdc1aa699fbe4acd1b5427befd04d1}{ecore\_loop\_time\_get}());
   printf(\textcolor{stringliteral}{"unix time: %0.3f\(\backslash\)n"}, \hyperlink{group__Ecore__Time__Group_ga4644b45bfca1495322913f9e529d82fc}{ecore\_time\_unix\_get}());

   \hyperlink{group__Ecore__Main__Loop__Group_ga329898ea4b32333c12c34cfde48326fd}{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;
     \}

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

\end{DoxyCodeInclude}
 