Strange Day of Week

Mark Guagenti mgenti at gentiweb.com
Wed Dec 22 16:37:01 UTC 2010


I'm using uClibc version 0.9.30.2 and my target has an ARM core.
--Mark

On Wed, Dec 22, 2010 at 10:07 AM, Denys Vlasenko
<vda.linux at googlemail.com> wrote:
> On Wed, Dec 22, 2010 at 4:27 PM, Mark Guagenti <mgenti at gentiweb.com> wrote:
>> For some reason the date command on my busybox (1.17.4) will not show
>> the correct day of the week.  No matter what I set the date to it
>> always shows "Sunday" as the day of the week. For example:
>> # date -s "2010-12-21 08:24:00"
>>  Sunday 21 08:24:00 MST 2010
>> # date -s "2010-12-22 08:24:00"
>> t Sunday 22 08:24:00 MST 2010
>> # date +%s
>> # date +%a
>> t
>> # date +%A
>>
>> I also tried setting the time with NTP but that doesn't seem to help.
>> Any suggestions on why my system is doing this?
>
> Not really. I can't reproduce it. I disabled actual date setting code,
> and added printouts in validate_tm_time() around mktime(ptm) call:
>
> # ./busybox date -s "2010-12-21 08:24:00"
> date: before:sec:0 min:24 hour:8 mday:21 mon:11 year:110 wday:3
> yday:355 isdst:-1
> date: after:sec:0 min:24 hour:8 mday:21 mon:11 year:110 wday:2 yday:354 isdst:0
> Tue Dec 21 08:24:00 CET 2010
> # ./busybox date -s "2010-12-22 08:24:00"
> date: before:sec:0 min:24 hour:8 mday:22 mon:11 year:110 wday:3
> yday:355 isdst:-1
> date: after:sec:0 min:24 hour:8 mday:22 mon:11 year:110 wday:3 yday:355 isdst:0
> Wed Dec 22 08:24:00 CET 2010
> # ./busybox date -s "2010-12-23 08:24:00"
> date: before:sec:0 min:24 hour:8 mday:23 mon:11 year:110 wday:3
> yday:355 isdst:-1
> date: after:sec:0 min:24 hour:8 mday:23 mon:11 year:110 wday:4 yday:356 isdst:0
> Thu Dec 23 08:24:00 CET 2010
>
> Look how wday changes.
> As you see, mktime() sets wday according to other fields, as documented
> in its manpage:
>
> "The mktime() function converts a broken-down time structure,
> expressed as local time,
> to calendar time representation. The function ignores the specified contents
> of the structure members tm_wday and tm_yday and recomputes them from
> the other information in the broken-down time structure."
>
> Looks like you are using buggy libc. Which libc do you use?
> --
> vda
>


More information about the busybox mailing list