Revision 2f254850 src/Ganeti/Utils.hs

b/src/Ganeti/Utils.hs
52 52
  , getCurrentTime
53 53
  , getCurrentTimeUSec
54 54
  , clockTimeToString
55
  , clockTimeToCTime
56
  , cTimeToClockTime
55 57
  , chompPrefix
56 58
  , warn
57 59
  , wrap
......
88 90
import Data.IORef
89 91
import Data.List
90 92
import qualified Data.Map as M
93
import Foreign.C.Types (CTime(..))
91 94
import Numeric (showOct)
92 95
import System.Directory (renameFile, createDirectoryIfMissing)
93 96
import System.FilePath.Posix (takeDirectory)
......
392 395
clockTimeToString :: ClockTime -> String
393 396
clockTimeToString (TOD t _) = show t
394 397

  
398
-- | Convert a ClockTime into a (seconds-only) 'EpochTime' (AKA @time_t@).
399
clockTimeToCTime :: ClockTime -> EpochTime
400
clockTimeToCTime (TOD secs _) = fromInteger secs
401

  
402
-- | Convert a ClockTime into a (seconds-only) 'EpochTime' (AKA @time_t@).
403
cTimeToClockTime :: EpochTime -> ClockTime
404
cTimeToClockTime (CTime timet) = TOD (toInteger timet) 0
405

  
395 406
{-| Strip a prefix from a string, allowing the last character of the prefix
396 407
(which is assumed to be a separator) to be absent from the string if the string
397 408
terminates there.

Also available in: Unified diff