handle tz updates with localtime - limit calls to more than 1 second apart.

SVN revision: 34553
This commit is contained in:
Carsten Haitzler 2008-05-13 05:14:19 +00:00
parent c014ed5267
commit ad70ab93f4
1 changed files with 6 additions and 0 deletions

View File

@ -29,6 +29,7 @@ _embryo_time_seconds(Embryo_Program *ep __UNUSED__, Embryo_Cell *params __UNUSED
static Embryo_Cell
_embryo_time_date(Embryo_Program *ep, Embryo_Cell *params)
{
static time_t last_tzset = 0;
struct timeval timev;
struct tm *tm;
time_t tt;
@ -36,6 +37,11 @@ _embryo_time_date(Embryo_Program *ep, Embryo_Cell *params)
if (params[0] != (8 * sizeof(Embryo_Cell))) return 0;
gettimeofday(&timev, NULL);
tt = (time_t)(timev.tv_sec);
if ((tt - last_tzset) < 1)
{
last_tzset = tt;
tzset();
}
tm = localtime(&tt);
if (tm)
{