[Pkg-haskell-commits] [SCM] haskell-testpack branch, master, updated. debian/1.0.2-1-4-gb0d6b36
John Goerzen
jgoerzen at complete.org
Fri Apr 23 14:55:37 UTC 2010
The following commit has been merged in the master branch:
commit 282539bfaa94bed2267fa9b2e98bedf18c222fff
Author: John Goerzen <jgoerzen at complete.org>
Date: Tue Apr 5 23:38:00 2005 +0100
Stage 1 of compatibility fixes for new fptools
Keywords:
(jgoerzen at complete.org--projects/missingh--head--0.7--patch-212)
diff --git a/ChangeLog b/ChangeLog
index 172f788..3bffacd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,19 @@
# arch-tag: automatic-ChangeLog--jgoerzen at complete.org--projects/missingh--head--0.7
#
+2005-04-05 17:38:00 GMT John Goerzen <jgoerzen at complete.org> patch-212
+
+ Summary:
+ Stage 1 of compatibility fixes for new fptools
+ Revision:
+ missingh--head--0.7--patch-212
+
+
+ modified files:
+ ChangeLog MissingH/IO/HVFS.hs MissingH/IO/HVFS/Utils.hs
+ MissingH/Time.hs debian/changelog
+
+
2005-04-05 16:47:01 GMT John Goerzen <jgoerzen at complete.org> patch-211
Summary:
diff --git a/MissingH/IO/HVFS.hs b/MissingH/IO/HVFS.hs
index a382cd6..22f763b 100644
--- a/MissingH/IO/HVFS.hs
+++ b/MissingH/IO/HVFS.hs
@@ -63,6 +63,7 @@ module MissingH.IO.HVFS(-- * Implementation Classes \/ Types
where
import MissingH.IO.HVIO
+import MissingH.Time
import System.IO
import System.IO.Error
import System.Posix.Files
@@ -85,7 +86,9 @@ Here is an example from the HVFS source:
> vGetModificationTime fs fp =
> do s <- vGetFileStatus fs fp
-> return $ TOD (fromIntegral (withStat s vModificationTime)) 0
+> return $ epochToClockTime (withStat s vModificationTime)
+
+See 'MissingH.Time.epochToClockTime' for more information.
-}
withStat :: forall b. HVFSStatEncap -> (forall a. HVFSStat a => a -> b) -> b
withStat s f =
@@ -197,7 +200,7 @@ class (Show a) => HVFS a where
vGetModificationTime fs fp =
do s <- vGetFileStatus fs fp
- return $ TOD (fromIntegral (withStat s vModificationTime)) 0
+ return $ epochToClockTime (withStat s vModificationTime)
vRaiseError _ et desc mfp =
ioError $ mkIOError et desc Nothing mfp
diff --git a/MissingH/IO/HVFS/Utils.hs b/MissingH/IO/HVFS/Utils.hs
index 6a2083c..f9a04d9 100644
--- a/MissingH/IO/HVFS/Utils.hs
+++ b/MissingH/IO/HVFS/Utils.hs
@@ -44,6 +44,7 @@ module MissingH.IO.HVFS.Utils (recurseDir,
where
import MissingH.IO.HVFS
+import MissingH.Time
import System.Posix.Files
import MissingH.Printf
import System.Time
@@ -122,7 +123,7 @@ lsl fs fp =
else if vIsSocket se then 's'
else if vIsNamedPipe se then 's'
else '-'
- clocktime = TOD (fromIntegral (vModificationTime se)) 0
+ clocktime = epochToClockTime (vModificationTime se)
datestr c= formatCalendarTime defaultTimeLocale "%b %e %Y"
c
in do c <- toCalendarTime clocktime
diff --git a/MissingH/Time.hs b/MissingH/Time.hs
index d6295b9..c8d4495 100644
--- a/MissingH/Time.hs
+++ b/MissingH/Time.hs
@@ -1,5 +1,5 @@
{- arch-tag: Time utilities main file
-Copyright (C) 2004 John Goerzen <jgoerzen at complete.org>
+Copyright (C) 2004-2005 John Goerzen <jgoerzen at complete.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : MissingH.Time
- Copyright : Copyright (C) 2004 John Goerzen
+ Copyright : Copyright (C) 2004-2005 John Goerzen
License : GNU GPL, version 2 or above
Maintainer : John Goerzen,
@@ -36,10 +36,12 @@ module MissingH.Time(
timelocal,
timegm,
timeDiffToSecs,
- epoch
+ epoch,
+ epochToClockTime
)
where
import System.Time
+import Data.Ratio
{- | January 1, 1970, midnight, UTC, represented as a CalendarTime. -}
epoch :: CalendarTime
@@ -95,3 +97,15 @@ timeDiffToSecs td =
24 * ((fromIntegral $ tdDay td) +
30 * ((fromIntegral $ tdMonth td) +
365 * (fromIntegral $ tdYear td)))))
+
+{- | Converts an Epoch time represented with an arbitrary Real to a ClockTime.
+This input could be a CTime from Foreign.C.Types or an EpochTime from
+System.Posix.Types. -}
+epochToClockTime :: Real a => a -> ClockTime
+epochToClockTime x =
+ TOD seconds secfrac
+ where ratval = toRational x
+ seconds = floor ratval
+ secfrac = floor $ (ratval - (seconds % 1) ) * picosecondfactor
+ picosecondfactor = 10 ^ 12
+
diff --git a/debian/changelog b/debian/changelog
index b5398b7..8f5d504 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,8 +1,10 @@
missingh (0.9.2) unstable; urgency=low
* New modules: MissingH.Debian, MissingH.Debian.ControlParser
- * Temporary changes to work with new Hugs
* New MissingH.List functions: wholeMap, fixedWidth
+ * New function: MissingH.Time.epochToClockTime
+ * Updated HVFS utilities to use epochToClockTime for compatibility
+ with the newer Hugs
-- John Goerzen <jgoerzen at complete.org> Tue, 15 Mar 2005 09:18:10 -0600
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list