5 #ifndef EFL_HAVE_GETTIMEOFDAY
6 # error "Your platform isn't supported yet"
13 # include <winsock2.h>
25 #include "embryo_private.h"
27 /* exported time api */
30 _embryo_time_seconds(Embryo_Program *ep __UNUSED__, Embryo_Cell *params __UNUSED__)
36 gettimeofday(&timev, NULL);
37 t = (double)(timev.tv_sec - ((timev.tv_sec / (60 * 60 * 24)) * (60 * 60 * 24)))
38 + (((double)timev.tv_usec) / 1000000);
40 return EMBRYO_FLOAT_TO_CELL(f);
44 _embryo_time_date(Embryo_Program *ep, Embryo_Cell *params)
46 static time_t last_tzset = 0;
51 if (params[0] != (8 * sizeof(Embryo_Cell))) return 0;
52 gettimeofday(&timev, NULL);
53 tt = (time_t)(timev.tv_sec);
54 if ((tt > (last_tzset + 1)) ||
55 (tt < (last_tzset - 1)))
67 cptr = embryo_data_address_get(ep, params[1]);
68 if (cptr) *cptr = tm->tm_year + 1900;
69 cptr = embryo_data_address_get(ep, params[2]);
70 if (cptr) *cptr = tm->tm_mon + 1;
71 cptr = embryo_data_address_get(ep, params[3]);
72 if (cptr) *cptr = tm->tm_mday;
73 cptr = embryo_data_address_get(ep, params[4]);
74 if (cptr) *cptr = tm->tm_yday;
75 cptr = embryo_data_address_get(ep, params[5]);
76 if (cptr) *cptr = (tm->tm_wday + 6) % 7;
77 cptr = embryo_data_address_get(ep, params[6]);
78 if (cptr) *cptr = tm->tm_hour;
79 cptr = embryo_data_address_get(ep, params[7]);
80 if (cptr) *cptr = tm->tm_min;
81 cptr = embryo_data_address_get(ep, params[8]);
82 t = (double)tm->tm_sec + (((double)timev.tv_usec) / 1000000);
84 if (cptr) *cptr = EMBRYO_FLOAT_TO_CELL(f);
90 /* functions used by the rest of embryo */
93 _embryo_time_init(Embryo_Program *ep)
95 embryo_program_native_call_add(ep, "seconds", _embryo_time_seconds);
96 embryo_program_native_call_add(ep, "date", _embryo_time_date);