[Ecls-list] Datetime bug (gmt?)

Juan Jose Garcia-Ripoll juanjose.garciaripoll at gmail.com
Thu Aug 2 14:16:24 UTC 2012


On Thu, Aug 2, 2012 at 4:01 PM, Stanislav Frolov <frolosofsky at gmail.com>wrote:

> I found in source next code
>
>   #if 0 && defined(HAVE_TZSET)
>   tzset();
>   mw = timezone/60;
>   #endif
>
> Why 0?
>

ECL cannot use tzset(). Since ECL is embedded in other programs, it is not
allowed to change the environment. Unfortunately, POSIX mandates a single
environment for all threads. This means there are functions that we are not
allowed to use.


> Simple test code 'tzset(); timezone/60/60'; evaluates in '-4'. So, problem
> in:
>
>   struct tm ltm, gtm;
>   time_t when = 0L;
>
>   ltm = *localtime(&when);
>   gtm = *gmtime(&when);
>
>   mw = (gtm.tm_min + 60 * gtm.tm_hour) - (ltm.tm_min + 60 * ltm.tm_hour);
>
>   if ((gtm.tm_wday + 1) % 7 == ltm.tm_wday)
>     mw -= 24*60;
>   else if (gtm.tm_wday == (ltm.tm_wday + 1) % 7)
>     mw += 24*60;
>
> But i don't understand this code :(


This code uses two functions, localtime() and gmtime() and computes the
difference in time produced by both of them. This is a way to compute the
timezone (difference in hours or halfs of hours from GMT). Maybe some part
of this is wrong, or maybe localtime() is wrong and does not contain
timezone information. What is the value of localtime() and gmtime() in your
system?

Juanjo

-- 
Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain)
http://juanjose.garciaripoll.googlepages.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20120802/c55cd0d8/attachment.html>


More information about the ecl-devel mailing list