[commit: packages/time] format-widths, ghc, improve-leapseconds, master, posix-perf, tasty, wip/travis: rename id to Timezone (126e42f)

git at git.haskell.org git at git.haskell.org
Fri Apr 21 16:43:56 UTC 2017


Repository : ssh://git@git.haskell.org/time

On branches: format-widths,ghc,improve-leapseconds,master,posix-perf,tasty,wip/travis
Link       : http://git.haskell.org/packages/time.git/commitdiff/126e42f0147dc3738fb5116ea1ee0062ecc91e88

>---------------------------------------------------------------

commit 126e42f0147dc3738fb5116ea1ee0062ecc91e88
Author: ashley <ashley at semantic.org>
Date:   Wed Apr 27 23:03:31 2005 -0700

    rename id to Timezone
    
    darcs-hash:20050428060331-ca2d0-3076a294d8177816b619226e48304a9b093c8cd5


>---------------------------------------------------------------

126e42f0147dc3738fb5116ea1ee0062ecc91e88
 System/Time/Calendar.hs | 34 +++++++++++++++++-----------------
 TestTime.hs             |  2 +-
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/System/Time/Calendar.hs b/System/Time/Calendar.hs
index 828a664..c5aea12 100644
--- a/System/Time/Calendar.hs
+++ b/System/Time/Calendar.hs
@@ -3,7 +3,7 @@
 module System.Time.Calendar
 (
 	-- time zones
-	TimeZone,timezoneToMinutes,minutesToTimezone,hoursToTimezone,utc,
+	Timezone,timezoneToMinutes,minutesToTimezone,hoursToTimezone,utc,
 
 	-- getting the locale time zone
 	getTimezone,getCurrentTimezone,
@@ -34,22 +34,22 @@ import Foreign
 import Foreign.C
 
 -- | count of minutes
-newtype TimeZone = MkTimeZone {
+newtype Timezone = MkTimezone {
 	timezoneToMinutes :: Int
 } deriving (Eq,Ord)
 
-minutesToTimezone :: Int -> TimeZone
-minutesToTimezone = MkTimeZone
+minutesToTimezone :: Int -> Timezone
+minutesToTimezone = MkTimezone
 
-hoursToTimezone :: Int -> TimeZone
+hoursToTimezone :: Int -> Timezone
 hoursToTimezone i = minutesToTimezone (60 * i)
 
-instance Show TimeZone where
-	show (MkTimeZone t) | t < 0 = '-':(show (MkTimeZone (negate t)))
-	show (MkTimeZone t) = (show2 (div t 60)) ++ (show2 (mod t 60))
+instance Show Timezone where
+	show (MkTimezone t) | t < 0 = '-':(show (MkTimezone (negate t)))
+	show (MkTimezone t) = (show2 (div t 60)) ++ (show2 (mod t 60))
 
 -- | The UTC time zone
-utc :: TimeZone
+utc :: Timezone
 utc = minutesToTimezone 0
 
 foreign import ccall unsafe "timestuff.h get_current_timezone_seconds" get_current_timezone_seconds :: CTime -> IO CLong
@@ -58,7 +58,7 @@ posixToCTime :: POSIXTime -> CTime
 posixToCTime  = fromInteger . floor
 
 -- | Get the local time-zone for a given time (varying as per summertime adjustments)
-getTimezone :: UTCTime -> IO TimeZone
+getTimezone :: UTCTime -> IO Timezone
 getTimezone time = do
 	secs <- get_current_timezone_seconds (posixToCTime (utcTimeToPOSIXSeconds time))
 	case secs of
@@ -66,7 +66,7 @@ getTimezone time = do
 		_ -> return (minutesToTimezone (div (fromIntegral secs) 60))
 
 -- | Get the current time-zone
-getCurrentTimezone :: IO TimeZone
+getCurrentTimezone :: IO Timezone
 getCurrentTimezone = getCurrentTime >>= getTimezone
 
 -- | time of day as represented in hour, minute and second (with picoseconds), typically used to express local time of day
@@ -151,14 +151,14 @@ calendarToDay (CalendarDay year month day) =
 	m = month' + (12 * a) - 3
 
 -- | convert a ToD in UTC to a ToD in some timezone, together with a day adjustment
-utcToLocalTimeOfDay :: TimeZone -> TimeOfDay -> (Integer,TimeOfDay)
-utcToLocalTimeOfDay (MkTimeZone tz) (TimeOfDay h m s) = (fromIntegral (div h' 24),TimeOfDay (mod h' 24) (mod m' 60) s) where
+utcToLocalTimeOfDay :: Timezone -> TimeOfDay -> (Integer,TimeOfDay)
+utcToLocalTimeOfDay (MkTimezone tz) (TimeOfDay h m s) = (fromIntegral (div h' 24),TimeOfDay (mod h' 24) (mod m' 60) s) where
 	m' = m + tz
 	h' = h + (div m' 60)
 
 -- | convert a ToD in some timezone to a ToD in UTC, together with a day adjustment
-localToUTCTimeOfDay :: TimeZone -> TimeOfDay -> (Integer,TimeOfDay)
-localToUTCTimeOfDay (MkTimeZone tz) = utcToLocalTimeOfDay (MkTimeZone (negate tz))
+localToUTCTimeOfDay :: Timezone -> TimeOfDay -> (Integer,TimeOfDay)
+localToUTCTimeOfDay (MkTimezone tz) = utcToLocalTimeOfDay (MkTimezone (negate tz))
 
 posixDay :: DiffTime
 posixDay = fromInteger 86400
@@ -179,12 +179,12 @@ timeOfDayToTime :: TimeOfDay -> DiffTime
 timeOfDayToTime (TimeOfDay h m s) = ((fromIntegral h) * 60 + (fromIntegral m)) * 60 + (realToFrac s)
 
 -- | show a UTC time in a given time zone as a CalendarTime
-utcToCalendar :: TimeZone -> UTCTime -> CalendarTime
+utcToCalendar :: Timezone -> UTCTime -> CalendarTime
 utcToCalendar tz (UTCTime day dt) = CalendarTime (dayToCalendar (day + i)) tod where
 	(i,tod) = utcToLocalTimeOfDay tz (timeToTimeOfDay dt)
 
 -- | find out what UTC time a given CalendarTime in a given time zone is
-calendarToUTC :: TimeZone -> CalendarTime -> UTCTime
+calendarToUTC :: Timezone -> CalendarTime -> UTCTime
 calendarToUTC tz (CalendarTime cday tod) = UTCTime (day + i) (timeOfDayToTime todUTC) where
 	day = calendarToDay cday
 	(i,todUTC) = localToUTCTimeOfDay tz tod
diff --git a/TestTime.hs b/TestTime.hs
index e4a2712..83d2141 100644
--- a/TestTime.hs
+++ b/TestTime.hs
@@ -41,7 +41,7 @@ for :: (Monad m) => (a -> m ()) -> [a] -> m ()
 for _ [] = return ()
 for f (x:xs) = f x >> for f xs
 
-myzone :: TimeZone
+myzone :: Timezone
 myzone = hoursToTimezone (- 8)
 
 leapSec1998Cal :: CalendarTime



More information about the ghc-commits mailing list