On Thu, Aug 2, 2012 at 4:01 PM, Stanislav Frolov <frolosof...@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
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ecls-list mailing list
Ecls-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ecls-list

Reply via email to