diff --git a/Data/Time/Calendar/Days.hs b/Data/Time/Calendar/Days.hs
--- a/Data/Time/Calendar/Days.hs
+++ b/Data/Time/Calendar/Days.hs
@@ -18,16 +18,13 @@
 newtype Day = ModifiedJulianDay {toModifiedJulianDay :: Integer} deriving (Eq,Ord
 #if LANGUAGE_DeriveDataTypeable
 #if LANGUAGE_Rank2Types
-    ,Data
+    ,Data, Typeable
 #endif
 #endif
     )
 
 instance NFData Day where
 	rnf (ModifiedJulianDay a) = rnf a
-
-instance Typeable Day where
-	typeOf _ = mkTyConApp (mkTyCon3 "time" "Data.Time.Calendar.Days" "Day") []
 
 -- necessary because H98 doesn't have "cunning newtype" derivation
 instance Enum Day where
diff --git a/Data/Time/Clock/CTimeval.hs b/Data/Time/Clock/CTimeval.hs
--- a/Data/Time/Clock/CTimeval.hs
+++ b/Data/Time/Clock/CTimeval.hs
@@ -25,10 +25,8 @@
 -- | Get the current POSIX time from the system clock.
 getCTimeval :: IO CTimeval
 getCTimeval = with (MkCTimeval 0 0) (\ptval -> do
-	result <- gettimeofday ptval nullPtr
-	if (result == 0)
-	 then peek ptval
-	 else fail ("error in gettimeofday: " ++ (show result))
+	throwErrnoIfMinus1_ "gettimeofday" $ gettimeofday ptval nullPtr
+	peek ptval
 	)
 
 #endif
diff --git a/Data/Time/Clock/Scale.hs b/Data/Time/Clock/Scale.hs
--- a/Data/Time/Clock/Scale.hs
+++ b/Data/Time/Clock/Scale.hs
@@ -25,7 +25,7 @@
 newtype UniversalTime = ModJulianDate {getModJulianDate :: Rational} deriving (Eq,Ord
 #if LANGUAGE_DeriveDataTypeable
 #if LANGUAGE_Rank2Types
-    ,Data
+    ,Data, Typeable
 #endif
 #endif
     )
@@ -34,9 +34,6 @@
 instance NFData UniversalTime where
 	rnf (ModJulianDate a) = rnf a
 
-instance Typeable UniversalTime where
-	typeOf _ = mkTyConApp (mkTyCon3 "time" "Data.Time.Clock.Scale" "UniversalTime") []
-
 -- | This is a length of time, as measured by a clock.
 -- Conversion functions will treat it as seconds.
 -- It has a precision of 10^-12 s.
@@ -44,7 +41,7 @@
 #if LANGUAGE_DeriveDataTypeable
 #if LANGUAGE_Rank2Types
 #if HAS_DataPico
-    ,Data
+    ,Data, Typeable
 #else
 #endif
 #endif
@@ -53,9 +50,6 @@
 
 -- necessary because H98 doesn't have "cunning newtype" derivation
 instance NFData DiffTime -- FIXME: Data.Fixed had no NFData instances yet at time of writing
-
-instance Typeable DiffTime where
-	typeOf _ = mkTyConApp (mkTyCon3 "time" "Data.Time.Clock.Scale" "DiffTime") []
 
 -- necessary because H98 doesn't have "cunning newtype" derivation
 instance Enum DiffTime where
diff --git a/Data/Time/Clock/TAI.hs b/Data/Time/Clock/TAI.hs
--- a/Data/Time/Clock/TAI.hs
+++ b/Data/Time/Clock/TAI.hs
@@ -30,7 +30,7 @@
 #if LANGUAGE_DeriveDataTypeable
 #if LANGUAGE_Rank2Types
 #if HAS_DataPico
-    ,Data
+    ,Data, Typeable
 #endif
 #endif
 #endif
@@ -38,9 +38,6 @@
 
 instance NFData AbsoluteTime where
 	rnf (MkAbsoluteTime a) = rnf a
-
-instance Typeable AbsoluteTime where
-	typeOf _ = mkTyConApp (mkTyCon3 "time" "Data.Time.Clock.TAI" "AbsoluteTime") []
 
 instance Show AbsoluteTime where
 	show t = show (utcToLocalTime utc (taiToUTCTime (const 0) t)) ++ " TAI" -- ugly, but standard apparently
diff --git a/Data/Time/Clock/UTC.hs b/Data/Time/Clock/UTC.hs
--- a/Data/Time/Clock/UTC.hs
+++ b/Data/Time/Clock/UTC.hs
@@ -36,7 +36,7 @@
 #if LANGUAGE_DeriveDataTypeable
 #if LANGUAGE_Rank2Types
 #if HAS_DataPico
-    deriving (Data)
+    deriving (Data, Typeable)
 #endif
 #endif
 #endif
@@ -44,9 +44,6 @@
 instance NFData UTCTime where
 	rnf (UTCTime d t) = d `deepseq` t `deepseq` ()
 
-instance Typeable UTCTime where
-	typeOf _ = mkTyConApp (mkTyCon3 "time" "Data.Time.Clock.UTC" "UTCTime") []
-
 instance Eq UTCTime where
 	(UTCTime da ta) == (UTCTime db tb) = (da == db) && (ta == tb)
 
@@ -65,7 +62,7 @@
 #if LANGUAGE_DeriveDataTypeable
 #if LANGUAGE_Rank2Types
 #if HAS_DataPico
-    ,Data
+    ,Data, Typeable
 #endif
 #endif
 #endif
@@ -73,9 +70,6 @@
 
 -- necessary because H98 doesn't have "cunning newtype" derivation
 instance NFData NominalDiffTime -- FIXME: Data.Fixed had no NFData instances yet at time of writing
-
-instance Typeable NominalDiffTime where
-	typeOf _ = mkTyConApp (mkTyCon3 "time" "Data.Time.Clock.UTC" "NominalDiffTime") []
 
 instance Enum NominalDiffTime where
 	succ (MkNominalDiffTime a) = MkNominalDiffTime (succ a)
diff --git a/Data/Time/LocalTime/LocalTime.hs b/Data/Time/LocalTime/LocalTime.hs
--- a/Data/Time/LocalTime/LocalTime.hs
+++ b/Data/Time/LocalTime/LocalTime.hs
@@ -34,7 +34,7 @@
 #if LANGUAGE_DeriveDataTypeable
 #if LANGUAGE_Rank2Types
 #if HAS_DataPico
-    ,Data
+    ,Data, Typeable
 #endif
 #endif
 #endif
@@ -43,9 +43,6 @@
 instance NFData LocalTime where
 	rnf (LocalTime d t) = d `deepseq` t `deepseq` ()
 
-instance Typeable LocalTime where
-	typeOf _ = mkTyConApp (mkTyCon3 "time" "Data.Time.LocalTime.LocalTime" "LocalTime") []
-
 instance Show LocalTime where
 	show (LocalTime d t) = (showGregorian d) ++ " " ++ (show t)
 
@@ -78,16 +75,13 @@
 #if LANGUAGE_DeriveDataTypeable
 #if LANGUAGE_Rank2Types
 #if HAS_DataPico
-    deriving (Data)
+    deriving (Data, Typeable)
 #endif
 #endif
 #endif
 
 instance NFData ZonedTime where
 	rnf (ZonedTime lt z) = lt `deepseq` z `deepseq` ()
-
-instance Typeable ZonedTime where
-	typeOf _ = mkTyConApp (mkTyCon3 "time" "Data.Time.LocalTime.LocalTime" "ZonedTime") []
 
 utcToZonedTime :: TimeZone -> UTCTime -> ZonedTime
 utcToZonedTime zone time = ZonedTime (utcToLocalTime zone time) zone
diff --git a/Data/Time/LocalTime/TimeOfDay.hs b/Data/Time/LocalTime/TimeOfDay.hs
--- a/Data/Time/LocalTime/TimeOfDay.hs
+++ b/Data/Time/LocalTime/TimeOfDay.hs
@@ -33,7 +33,7 @@
 #if LANGUAGE_DeriveDataTypeable
 #if LANGUAGE_Rank2Types
 #if HAS_DataPico
-    ,Data
+    ,Data, Typeable
 #endif
 #endif
 #endif
@@ -41,9 +41,6 @@
 
 instance NFData TimeOfDay where
 	rnf (TimeOfDay h m s) = h `deepseq` m `deepseq` s `seq` () -- FIXME: Data.Fixed had no NFData instances yet at time of writing
-
-instance Typeable TimeOfDay where
-	typeOf _ = mkTyConApp (mkTyCon3 "time" "Data.Time.LocalTime.TimeOfDay" "TimeOfDay") []
 
 -- | Hour zero
 midnight :: TimeOfDay
diff --git a/Data/Time/LocalTime/TimeZone.hs b/Data/Time/LocalTime/TimeZone.hs
--- a/Data/Time/LocalTime/TimeZone.hs
+++ b/Data/Time/LocalTime/TimeZone.hs
@@ -36,16 +36,13 @@
 } deriving (Eq,Ord
 #if LANGUAGE_DeriveDataTypeable
 #if LANGUAGE_Rank2Types
-    ,Data
+    ,Data, Typeable
 #endif
 #endif
     )
 
 instance NFData TimeZone where
 	rnf (TimeZone m so n) = m `deepseq` so `deepseq` n `deepseq` ()
-
-instance Typeable TimeZone where
-	typeOf _ = mkTyConApp (mkTyCon3 "time" "Data.Time.LocalTime.TimeZone" "TimeZone") []
 
 -- | Create a nameless non-summer timezone for this number of minutes
 minutesToTimeZone :: Int -> TimeZone
diff --git a/Test/TestTimeZone.hs b/Test/TestTimeZone.hs
new file mode 100644
--- /dev/null
+++ b/Test/TestTimeZone.hs
@@ -0,0 +1,17 @@
+{-# OPTIONS -Wall -Werror #-}
+
+module Test.TestTimeZone where
+
+import Data.Time
+import System.Posix.Env (putEnv)
+import Test.TestUtil
+
+testTimeZone :: Test
+testTimeZone = ioTest "getTimeZone respects TZ env var" $ do
+  putEnv "TZ=UTC+0"
+  zone1 <- getTimeZone epoch
+  putEnv "TZ=EST+5"
+  zone2 <- getTimeZone epoch
+  return $ diff False (zone1 == zone2)
+ where
+  epoch = UTCTime (ModifiedJulianDay 0) 0
diff --git a/Test/Tests.hs b/Test/Tests.hs
--- a/Test/Tests.hs
+++ b/Test/Tests.hs
@@ -13,6 +13,7 @@
 import Test.TestParseDAT
 import Test.TestParseTime
 import Test.TestTime
+import Test.TestTimeZone
 
 tests :: [Test]
 tests = [ addDaysTest
@@ -25,4 +26,5 @@
         , testMonthDay
         , testParseDAT
         , testParseTime
-        , testTime ]
+        , testTime
+        , testTimeZone ]
diff --git a/cbits/HsTime.c b/cbits/HsTime.c
--- a/cbits/HsTime.c
+++ b/cbits/HsTime.c
@@ -4,37 +4,38 @@
 long int get_current_timezone_seconds (time_t t,int* pdst,char const* * pname)
 {
 #if HAVE_LOCALTIME_R
-	struct tm tmd;
-	struct tm* ptm = localtime_r(&t,&tmd);
+    struct tm tmd;
+    tzset();
+    struct tm* ptm = localtime_r(&t,&tmd);
 #else
-	struct tm* ptm = localtime(&t);
+    struct tm* ptm = localtime(&t);
 #endif
-	if (ptm)
-	{
-		int dst = ptm -> tm_isdst;
-		*pdst = dst;
+    if (ptm)
+    {
+        int dst = ptm -> tm_isdst;
+        *pdst = dst;
 #if HAVE_TM_ZONE
-		*pname = ptm -> tm_zone;
-		return ptm -> tm_gmtoff;
+        *pname = ptm -> tm_zone;
+        return ptm -> tm_gmtoff;
 #elif defined(_MSC_VER) || defined(__MINGW32__) || defined(_WIN32)
-		// We don't have a better API to use on Windows, the logic to
-		// decide whether a given date/time falls within DST is
-		// implemented as part of localtime() in the CRT.  This is_dst
-		// flag is all we need here.
-		*pname = dst ? _tzname[1] : _tzname[0];
-		return - (dst ? _timezone - 3600 : _timezone);
+        // We don't have a better API to use on Windows, the logic to
+        // decide whether a given date/time falls within DST is
+        // implemented as part of localtime() in the CRT.  This is_dst
+        // flag is all we need here.
+        *pname = dst ? _tzname[1] : _tzname[0];
+        return - (dst ? _timezone - 3600 : _timezone);
 #else
 # if HAVE_TZNAME
-		*pname = *tzname;
+        *pname = *tzname;
 # else
 #  error "Don't know how to get timezone name on your OS"
 # endif
 # if HAVE_DECL_ALTZONE
-		return dst ? altzone : timezone;
+        return dst ? altzone : timezone;
 # else
-		return dst ? timezone - 3600 : timezone;
+        return dst ? timezone - 3600 : timezone;
 # endif
 #endif // HAVE_TM_ZONE
-	}
-	else return 0x80000000;
+    }
+    else return 0x80000000;
 }
diff --git a/time.cabal b/time.cabal
--- a/time.cabal
+++ b/time.cabal
@@ -1,5 +1,5 @@
 name:           time
-version:        1.4.0.2
+version:        1.4.1
 stability:      stable
 license:        BSD3
 license-file:   LICENSE
@@ -114,8 +114,9 @@
         old-locale,
         process,
         QuickCheck >= 2.5.1,
-        test-framework >= 0.6.1,
-        test-framework-quickcheck2 >= 0.2.12
+        test-framework >= 0.6.1 && < 0.7,
+        test-framework-quickcheck2 >= 0.2.12,
+        unix
     main-is: Test.hs
     other-modules:
         Test.Tests
