Hi, working with the DS1921 Thermochron iButton I noticed that, when writing a time value to clock/udate and reading it immediately afterwards, the returned value differs notably to the written value. This is dependent on the local time zone and whether it's daylight saving time or not. My environment variable TZ usually reads "Europe/Berlin". In the following example there's a difference of 3600 seconds i.e. 1 hour between the two values.
$ ./owwrite -s 3000 21.D5542E000000/clock/udate 1352387000; ./owread -s 3000 21.D5542E000000/clock/udate 1352383400 Looking at the source code, I discovered that the function mktime is used to convert a struct tm to time_t. However mktime uses the local time zone which explains the time shift. The following workaround makes the time shift disappear: just set the TZ environment variable to UTC when invoking the server. TZ=UTC ./owserver -u -p 3000 There's a function timegm which is basically the opposite part to gmtime. The latter is already used in the code when writing a udate value to the iButton. In my opinion timegm would be more suitable than mktime. I developed a patch to fix this issue, see attachment. BTW: I already submitted this patch last year Nov 8 to this list, but I never got any feedback - just in case this sounds familiar. Best regards Clemens Egger -- Clemens Egger Center for Biomedicine EURAC research Galvanistr. 31, I-39100 Bozen t +39 0471 055 524 f +39 0471 055 599 [email protected] www.eurac.edu
patch3.3_utc_issue_timegm_insteadof_mktime
Description: patch3.3_utc_issue_timegm_insteadof_mktime
------------------------------------------------------------------------------ Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. ON SALE this month only -- learn more at: http://p.sf.net/sfu/learnnow-d2d
_______________________________________________ Owfs-developers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/owfs-developers
