Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion tests/testTZSys.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Data.Int
import Data.Time
import Data.Time.Clock.POSIX
import Data.Time.Zones
import Data.Time.Zones.Read (pathForSystemTZ)
import System.Environment
import System.IO.Unsafe
import Test.Framework.Providers.QuickCheck2
Expand All @@ -21,7 +22,13 @@ foreign import ccall safe "time.h tzset" c_tzset :: IO ()

setupTZ :: String -> IO TZ
setupTZ zoneName = do
setEnv "TZ" zoneName
-- tzset(3) doesn't necessarily understand TZDIR, since it is
-- not mandated by POSIX. To avoid trouble with non-glibc
-- libc implementations (musl, libSystem, ...) we set TZ
-- to an absolute path (with a leading ':') which all
-- POSIX-conforming implementations must support.
tzPath <- pathForSystemTZ zoneName
setEnv "TZ" $ ":" ++ tzPath
c_tzset
loadSystemTZ zoneName

Expand Down