sb-unix::get-timezone is broken on Windows 10

Bug #1641058 reported by Kentaro Nakazawa on 2016-11-11
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Undecided
Unassigned

Bug Description

I noticed that (get-decoded-time) always returns the wrong value on Windows 10.
(get-decoded-time) is always correct on Linux.

SBCL downloaded the binary from http://sbcl.org/platform-table.html and installed it.
(Linux AMD64 and Windows AMD64)

Linux (Fedora 24 64bit)
CL-USER> (get-decoded-time)
20
6
1
11
11
2016
4
NIL <- correct
-9

Windows10 (64bit)
CL-USER> (get-decoded-time)
20
6
1
11
11
2016
4
T <- incorrect
-8

I checked the cause of the bug.

sbcl-1.3.11/src/code/unix.lisp:
(define-alien-routine get-timezone int
  (when time-t)
  (daylight-savings-p boolean :out)) <- This function returns an incorrect value.

sbcl-1.3.11/src/runtime/time.c:
int get_timezone(time_t when, boolean *dst)
{
    ....

    *dst = ltm.tm_isdst;

    /* I added an output for debugging. */
    printf("DEBUG: get_timezone(): ltm.tm_isdst is %d, *dst is %d\n", ltm.tm_isdst, *dst);

    return sw;
}

$ sbcl --noinform --no-userinit --non-interactive --eval '(print (multiple-value-list (sb-unix::get-timezone 3687784410)))'
=> (-32400 T) DEBUG: get_timezone(): ltm.tm_isdst is 0, *dst is 0

-32400(= -9 * 60 * 60) is correct.
T is incorrect.

Although *dst is 0, I do not know the reason why return value becomes T only in Windows.

Stas Boukarev (stassats) wrote :

#914612 is actually the reason for this.

Stas Boukarev (stassats) wrote :
Changed in sbcl:
status: New → Triaged
Stas Boukarev (stassats) wrote :

In 377a1292e208877d0aa260d49baf85564933de43

Changed in sbcl:
status: Triaged → Fix Committed

Thank you! I confirmed that it has been corrected.

Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers