Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

poke and peek aren't inverses for TIME_ZONE_INFORMATION #64

Closed
RyanGlScott opened this issue Dec 17, 2016 · 0 comments · Fixed by #65
Closed

poke and peek aren't inverses for TIME_ZONE_INFORMATION #64

RyanGlScott opened this issue Dec 17, 2016 · 0 comments · Fixed by #65

Comments

@RyanGlScott
Copy link
Member

module Main where

import Control.Exception (assert)
import Foreign
import System.Win32.Time

main :: IO ()
main = do
    (_, tzi) <- getTimeZoneInformation
    alloca $ \buf -> do
        poke buf tzi
        tzi' <- peek buf
        print tzi
        print tzi'
        assert (tzi == tzi') $ return ()
$ runghc TZI.hs
TIME_ZONE_INFORMATION {tziBias = 300, tziStandardName = "Eastern Standard Time", tziStandardDate = SYSTEMTIME {wYear = 0, wMonth = 11, wDayOfWeek = 0, wDay = 1, wHour = 2, wMinute = 0, wSecond = 0, wMilliseconds = 0}, tziStandardBias = 0, tziDaylightName = "Eastern Daylight Time", tziDaylightDate = SYSTEMTIME {wYear = 0, wMonth = 3, wDayOfWeek = 0, wDay = 2, wHour = 2, wMinute = 0, wSecond = 0, wMilliseconds = 0}, tziDaylightBias = -60}
TIME_ZONE_INFORMATION {tziBias = 300, tziStandardName = "", tziStandardDate = SYSTEMTIME {wYear = 0, wMonth = 11, wDayOfWeek = 0, wDay = 1, wHour = 2, wMinute = 0, wSecond = 0, wMilliseconds = 0}, tziStandardBias = 0, tziDaylightName = "\54232\2564", tziDaylightDate = SYSTEMTIME {wYear = 0, wMonth = 3, wDayOfWeek = 0, wDay = 2, wHour = 2, wMinute = 0, wSecond = 0, wMilliseconds = 0}, tziDaylightBias = -60}
TZI.hs: Assertion failed
CallStack (from HasCallStack):
  assert, called at TZI.hs:15:9 in main:Main

You'll notice that tzi and tzi' are almost the same, but their String values are different. I believe I know what's causing this, so I'll open a PR to fix it.

bgamari pushed a commit to bgamari/win32 that referenced this issue Sep 10, 2020
Make sections Markdown correct in README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant