История изменений
Исправление qnikst, (текущая версия) :
print . timeZoneMinutes . zonedTimeZone =<< getZonedTime
> 240
getZonedTime :: IO ZonedTime
getZonedTime = do
t <- getCurrentTime
zone <- getTimeZone t
return (utcToZonedTime zone t)
-- | Get the local time-zone for a given time (varying as per summertime adjustments)
getTimeZone :: UTCTime -> IO TimeZone
getTimeZone time = with 0 (\pdst -> with nullPtr (\pcname -> do
secs <- get_current_timezone_seconds (posixToCTime (utcTimeToPOSIXSeconds time)) pdst pcname
case secs of
0x80000000 -> fail "localtime_r failed"
_ -> do
dst <- peek pdst
cname <- peek pcname
name <- peekCString cname
return (TimeZone (div (fromIntegral secs) 60) (dst == 1) name)
))
т.е. при получении текущей TZ он честно берёт данные из системы, при парсе, откуда брать неясно, поэтому тебе тупо выдается имя таймзоны с пустыми настройками. Дальше ты можешь брать свою бд таймзон (/usr/share/zoneinfo) библиотеку умеющую их парсить (timezone-olson) и получаешь данные по твоей TZ.
Исходная версия qnikst, :
print . timeZoneMinutes . zonedTimeZone =<< getZonedTime
> 240
getZonedTime :: IO ZonedTime
getZonedTime = do
t <- getCurrentTime
zone <- getTimeZone t
return (utcToZonedTime zone t)
-- | Get the local time-zone for a given time (varying as per summertime adjustments)
getTimeZone :: UTCTime -> IO TimeZone
getTimeZone time = with 0 (\pdst -> with nullPtr (\pcname -> do
secs <- get_current_timezone_seconds (posixToCTime (utcTimeToPOSIXSeconds time)) pdst pcname
case secs of
0x80000000 -> fail "localtime_r failed"
_ -> do
dst <- peek pdst
cname <- peek pcname
name <- peekCString cname
return (TimeZone (div (fromIntegral secs) 60) (dst == 1) name)
))
т.е. при получении текущей TZ он честно берёт данные из системы, при парсе, откуда брать неясно, поэтому тебе тупо выдается имя таймзоны с пустыми настройками. Дальше ты можешь брать свою бд таймзон (/usr/share/zoneinfo) библиотеку умеющую их парсить (timezone-olson) и получаешь данные по твоей TZ.