hs-hourglass
hs-hourglass copied to clipboard
timezoneCurrent is very incorrect on Raspberry Pi, and slightly incorrect on desktop systems
I'm finding that Hourglass's timezoneCurrent
function is returning a wildly incorrect value on my Raspberry Pi, even though the date
command-line program correctly determines that the time zone is Pacific Daylight Time (-0700). Furthermore, timezoneCurrent
seems to return a different value each time I run my test program on the Raspberry Pi.
Here is my test program:
{-# LANGUAGE CPP #-}
import Data.Hourglass
import Time.System
import System.Process
timeFmt = [ Format_MonthName_Short , space , Format_Day2, space, Format_Year4
, space , Format_Hour, colon, Format_Minute, colon, Format_Second
, space , Format_TimezoneName, space, Format_TzHM_Colon ]
where colon = Format_Text ':'
space = Format_Text ' '
main = do
putStrLn "output of 'uname -a'"
callCommand "uname -a"
putStrLn "output of 'date'"
callCommand "date"
putStrLn $ "timeCurrent with hourglass-" ++ VERSION_hourglass
utc <- timeCurrent
putStrLn $ timePrint timeFmt utc
putStrLn $ "dateCurrent with hourglass-" ++ VERSION_hourglass
utc' <- dateCurrent
putStrLn $ timePrint timeFmt utc'
putStrLn $ "localDateCurrent with hourglass-" ++ VERSION_hourglass
local <- localDateCurrent
putStrLn $ localTimePrint timeFmt local
putStrLn $ "timezoneCurrent with hourglass-" ++ VERSION_hourglass
offset <- timezoneCurrent
print offset
And here is an example of the output it produces on my Raspberry Pi:
output of 'uname -a'
Linux xmaslites 4.4.34+ #930 Wed Nov 23 15:12:30 GMT 2016 armv6l GNU/Linux
output of 'date'
Sat 8 Apr 15:08:05 PDT 2017
timeCurrent with hourglass-0.2.10
Apr 08 2017 22:08:05 +00:00
dateCurrent with hourglass-0.2.10
Apr 08 2017 22:08:05 +00:00
localDateCurrent with hourglass-0.2.10
May 24 2018 17:33:05 +59:25
timezoneCurrent with hourglass-0.2.10
+5925
I tried my test program on a couple of desktop systems, and it seems to work better there, in that the time zone is not random. However, on the desktop systems I tried, Hourglass is determining the time zone offset to be -0800 instead of -0700, so it's still not quite right.
output of 'uname -a'
Linux patrick64 4.4.0-21-generic #37-Ubuntu SMP Mon Apr 18 18:33:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
output of 'date'
Sat Apr 8 15:18:30 PDT 2017
timeCurrent with hourglass-0.2.10
Apr 08 2017 22:18:30 +00:00
dateCurrent with hourglass-0.2.10
Apr 08 2017 22:18:30 +00:00
localDateCurrent with hourglass-0.2.10
Apr 08 2017 14:18:30 -08:00
timezoneCurrent with hourglass-0.2.10
-0800
Here is a repository for my test program.