--
-- clockTimeToDate relies on a non-standard implementation of Time,
-- i.e., one which exports ClockTime non-abstractly.
-- 
clockTimeToDate :: ClockTime -> IO Date
clockTimeToDate (TOD secs _) 
  | secs > fromIntegral (maxBound :: Int) ||
    secs < fromIntegral (minBound :: Int) = 
    ioError (userError "Automation.clockTimeToDate: ClockTime out of range")
  | otherwise = primClockToDate (fromIntegral secs)
clockTimeToDate :: ClockTime -> IO Date
clockTimeToDate (TOD secs _) 
  | secs > fromIntegral (maxBound :: Int) ||
    secs < fromIntegral (minBound :: Int) = 
    ioError (userError "Automation.clockTimeToDate: ClockTime out of range")
  | otherwise = primClockToDate (fromIntegral secs)
clockTimeToDate (TOD secs _) 
  | secs > fromIntegral (maxBound :: Int) ||
    secs < fromIntegral (minBound :: Int) = 
    ioError (userError "Automation.clockTimeToDate: ClockTime out of range")
  | otherwise = primClockToDate (fromIntegral secs)