date issue with time_t value near dst switch (test, patch)

Alexey Soloviev EXT-Alexey.Soloviev at nokia.com
Thu Dec 30 07:57:41 UTC 2010


Hello,
I haven't received any feedback to my post about date issue.
I'd very appreciate any even negative.
Now I've added to patch a few tests for date with time_t values.
Also I've done thorough automated testing of patched busybox date 
handling time_t values
 comparing output with date from Debian Lenny's coreutils.
Any notes, comments and questions are welcome.

Best Regards,
Alexey.


ext Alexey Soloviev пишет:
>
> Hello,
> There is an issue with date utility when using time_t values (unix time)
> in 1 hour before autumn's DST switch off. Result time is 1hr in advance.
> To reproduce set e.g. Helsinki timezone (e.g."export
> TZ=Europe/Helsinki") and
> type: "date @1288486799 ; date +%s"
>
> Expected outcome is
> Sun Oct 31 03:59:59 EEST 2010
> 1288486799
>
> Actual outcome is
> Sun Oct 31 03:59:59 EET 2010
> 1288490399
>
> coreutils date from Debian lenny works as expected.
>
> As I see, busybox date does the following
>   1) Gets current time as time_t (unix time)
>   2) Calls localtime_r to convert it to tm structure (human readable)
>   3) Parses argument, which is in time_t already, converts to tm using
> localtime
>   4) Invalidates DST value by setting isdst=-1 and calls mktime to get
> time_t
> value that is then used to set system time
>
> The problem is without respecting dst value of time, we get into time
> interval
> that happens twice both before DST is switched off and after it's
> switched off
> and time gets 1hr back. So only dst value could tell if DST already
> switched or
> not. And mktime assumes that received time is after DST switch,
> which is not true in the case.
>
> Suggested fix is to invalidate dst only if time is not in time_t format
> (check for @ prefix).
>
> I've attached the patch and a test. The test can be run with runtest 
> or like
>  sh date- at -works || echo 'FAIL'
>
> I'd appreciate any comments on my 1st post to this maillist.
>
> Best Regards, Alexey.
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Preserve-isdst-value-if-date-is-in-time_t-unix-time.patch
Type: text/x-patch
Size: 1729 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20101230/c6243f3a/attachment.bin>


More information about the busybox mailing list