aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/embryo/src/lib/embryo_time.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2013-01-13 17:29:19 +1000
committerDavid Walter Seikel2013-01-13 17:29:19 +1000
commit07274513e984f0b5544586c74508ccd16e7dcafa (patch)
treeb32ff2a9136fbc1a4a6a0ed1e4d79cde0f5f16d9 /libraries/embryo/src/lib/embryo_time.c
parentAdded Irrlicht 1.8, but without all the Windows binaries. (diff)
downloadSledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.zip
SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.gz
SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.bz2
SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.xz
Remove EFL, since it's been released now.
Diffstat (limited to '')
-rw-r--r--libraries/embryo/src/lib/embryo_time.c97
1 files changed, 0 insertions, 97 deletions
diff --git a/libraries/embryo/src/lib/embryo_time.c b/libraries/embryo/src/lib/embryo_time.c
deleted file mode 100644
index 90c14cf..0000000
--- a/libraries/embryo/src/lib/embryo_time.c
+++ /dev/null
@@ -1,97 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#ifndef EFL_HAVE_GETTIMEOFDAY
6# error "Your platform isn't supported yet"
7#endif
8
9#include <sys/time.h>
10#include <time.h>
11
12#ifdef _MSC_VER
13# include <winsock2.h>
14#endif
15
16#ifdef HAVE_EVIL
17# include <Evil.h>
18#endif
19
20#ifdef HAVE_EXOTIC
21# include <Exotic.h>
22#endif
23
24#include "Embryo.h"
25#include "embryo_private.h"
26
27/* exported time api */
28
29static Embryo_Cell
30_embryo_time_seconds(Embryo_Program *ep __UNUSED__, Embryo_Cell *params __UNUSED__)
31{
32 struct timeval timev;
33 double t;
34 float f;
35
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);
39 f = (float)t;
40 return EMBRYO_FLOAT_TO_CELL(f);
41}
42
43static Embryo_Cell
44_embryo_time_date(Embryo_Program *ep, Embryo_Cell *params)
45{
46 static time_t last_tzset = 0;
47 struct timeval timev;
48 struct tm *tm;
49 time_t tt;
50
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)))
56 {
57 last_tzset = tt;
58 tzset();
59 }
60 tm = localtime(&tt);
61 if (tm)
62 {
63 Embryo_Cell *cptr;
64 double t;
65 float f;
66
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);
83 f = (float)t;
84 if (cptr) *cptr = EMBRYO_FLOAT_TO_CELL(f);
85
86 }
87 return 0;
88}
89
90/* functions used by the rest of embryo */
91
92void
93_embryo_time_init(Embryo_Program *ep)
94{
95 embryo_program_native_call_add(ep, "seconds", _embryo_time_seconds);
96 embryo_program_native_call_add(ep, "date", _embryo_time_date);
97}