Opened 3 years ago
Last modified 3 months ago
#8914 assigned bug
Incorrect behaviour with POSIX TZ environment variable
| Reported by: | edglex | Owned by: | zooey |
|---|---|---|---|
| Priority: | normal | Milestone: | Unscheduled |
| Component: | System/POSIX | Version: | R1/Development |
| Keywords: | Cc: | ||
| Blocked By: | Blocking: | ||
| Has a Patch: | no | Platform: | All |
Description
According to http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html
"The contents of the environment variable named TZ shall be used by the ctime(), localtime(), strftime(), mktime(), [TSF] ctime_r(), and localtime_r() functions, and by various utilities, to override the default timezone." (on POSIX systems)
This causes a regression test of swi prolog to fail unless the timezone is manually set to CET.
Attachments (1)
Change History (10)
comment:1 Changed 3 years ago by zooey
- Owner changed from nobody to zooey
- Status changed from new to assigned
comment:2 follow-up: ↓ 3 Changed 3 years ago by zooey
comment:3 in reply to: ↑ 2 ; follow-up: ↓ 4 Changed 3 years ago by edglex
Replying to zooey:
TZ is not being ignored by Haiku, try this:
TZ=EST date
At least for me, this shows the date in EST timezone (which isn't my native one).
I am now unsure if the bug lies with swi-prolog or haiku, because running "TZ=CEST date" does indeed show me a date in CEST, but "TZ=CET" does not seem to do anything, while "TZ=CET+00:00" causes the swi-prolog tests to pass even though they complain about not getting the expected output. I'm not sure I understand the function of TZ well enough to know what to do about this, but this bug report does indeed seem to be incorrect, or at least about the wrong thing.
I've tried to build swi-prolog, but failed (see bug 626 on haiku-ports for the details).
Can you tell me which of the tests fails?
swi-prolog is building for you now.. so I guess you know the test that is failing - the tests in 'library.pl' which check the output format of various date/time functions. In the main testing script (run by make check) TZ is set to "CET".
comment:4 in reply to: ↑ 3 ; follow-up: ↓ 6 Changed 3 years ago by zooey
Replying to edglex:
Replying to zooey:
TZ is not being ignored by Haiku, try this:
TZ=EST date
At least for me, this shows the date in EST timezone (which isn't my native one).
I am now unsure if the bug lies with swi-prolog or haiku, because running "TZ=CEST date" does indeed show me a date in CEST, but "TZ=CET" does not seem to do anything, while "TZ=CET+00:00" causes the swi-prolog tests to pass even though they complain about not getting the expected output. I'm not sure I understand the function of TZ well enough to know what to do about this, but this bug report does indeed seem to be incorrect, or at least about the wrong thing.
I don't think this bug report is invalid. Maybe there's a problem in both swi-prolog and Haiku. When I played with TZ a bit on Haiku, I noticed that "TZ=EST date" works as intended, but "TZ=CEST date" does not: the latter shows the string "CEST" as timezone, but the printed date actually is the UTC date.
I've tried to build swi-prolog, but failed (see bug 626 on haiku-ports for the details).
Can you tell me which of the tests fails?
swi-prolog is building for you now.. so I guess you know the test that is failing - the tests in 'library.pl' which check the output format of various date/time functions. In the main testing script (run by make check) TZ is set to "CET".
Yes, I've noticed the failing tests, some of which may have wrong expectations, but others seem to indicate a problem with Haiku.
I'll continue to investigate when I find the time.
comment:5 Changed 3 years ago by edglex
- Summary changed from Haiku ignores POSIX TZ environment variable to Incorrect behaviour with POSIX TZ environment variable
comment:6 in reply to: ↑ 4 Changed 3 years ago by edglex
Replying to zooey:
I'll continue to investigate when I find the time.
Thanks.
For what its worth, running the swi-prolog test with TZ set to CET-02:00 it passes all the format tests except checking the actual time zone. Output is:
'%Z': got 'CET-02:00', expected 'CEST'
comment:7 Changed 8 months ago by luroh
- Milestone changed from R1 to Unscheduled
Move POSIX compatibility related tickets out of R1 milestone (FutureHaiku/Features).
Changed 3 months ago by jessicah
comment:8 Changed 3 months ago by jessicah
I am experiencing similar issues around mktime(), which causes an off-by-one error with the tm.tm_sec field, depending on the configured/specified timezone.
For example, in New Zealand, the test fails; indeed, setting the timezone in the Time preflet to any value of GMT+N:00 will cause the test to fail. Setting the timezone to GMT or GMT-N:00 will pass.
Using the TZ environment variable, TZ=GMT-12:00 ./time-failure fails here, whilst TZ=GMT+12:00 ./time-failure succeeds.
comment:9 Changed 3 months ago by jessicah
A quick run of the same on OS X doesn't trigger any assertion failures, fwiw.

TZ is not being ignored by Haiku, try this:
At least for me, this shows the date in EST timezone (which isn't my native one).
I've tried to build swi-prolog, but failed (see bug 626 on haiku-ports for the details).
Can you tell me which of the tests fails?