summaryrefslogtreecommitdiff
path: root/legacy/embryo/src/lib/embryo_time.c
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2008-05-13 05:14:19 +0000
committerCarsten Haitzler <raster@rasterman.com>2008-05-13 05:14:19 +0000
commitad70ab93f42c8445efc4ce4cfdc43c986baa098f (patch)
tree044d0cd268608256a7995823137b26092cd49fe5 /legacy/embryo/src/lib/embryo_time.c
parentc014ed5267c18bdcd1449970d592972e89f7886f (diff)
handle tz updates with localtime - limit calls to more than 1 second apart.
SVN revision: 34553
Diffstat (limited to '')
-rw-r--r--legacy/embryo/src/lib/embryo_time.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/legacy/embryo/src/lib/embryo_time.c b/legacy/embryo/src/lib/embryo_time.c
index e0794c3bb8..48112fd4b7 100644
--- a/legacy/embryo/src/lib/embryo_time.c
+++ b/legacy/embryo/src/lib/embryo_time.c
@@ -29,6 +29,7 @@ _embryo_time_seconds(Embryo_Program *ep __UNUSED__, Embryo_Cell *params __UNUSED
29static Embryo_Cell 29static Embryo_Cell
30_embryo_time_date(Embryo_Program *ep, Embryo_Cell *params) 30_embryo_time_date(Embryo_Program *ep, Embryo_Cell *params)
31{ 31{
32 static time_t last_tzset = 0;
32 struct timeval timev; 33 struct timeval timev;
33 struct tm *tm; 34 struct tm *tm;
34 time_t tt; 35 time_t tt;
@@ -36,6 +37,11 @@ _embryo_time_date(Embryo_Program *ep, Embryo_Cell *params)
36 if (params[0] != (8 * sizeof(Embryo_Cell))) return 0; 37 if (params[0] != (8 * sizeof(Embryo_Cell))) return 0;
37 gettimeofday(&timev, NULL); 38 gettimeofday(&timev, NULL);
38 tt = (time_t)(timev.tv_sec); 39 tt = (time_t)(timev.tv_sec);
40 if ((tt - last_tzset) < 1)
41 {
42 last_tzset = tt;
43 tzset();
44 }
39 tm = localtime(&tt); 45 tm = localtime(&tt);
40 if (tm) 46 if (tm)
41 { 47 {