[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:54:14 UTC 2010


The following commit has been merged in the master branch:
commit a72264f5491240418f17ca58b5b6cdac4586729a
Author: John Goerzen <jgoerzen at complete.org>
Date:   Fri Jan 21 08:34:27 2005 +0100

    Updated
    
    Keywords:
    
    
    (jgoerzen at complete.org--projects/missingh--head--0.7--patch-173)

diff --git a/ChangeLog b/ChangeLog
index 6cd07d7..68f7ca7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,18 @@
 # arch-tag: automatic-ChangeLog--jgoerzen at complete.org--projects/missingh--head--0.7
 #
 
+2005-01-21 01:34:27 GMT	John Goerzen <jgoerzen at complete.org>	patch-173
+
+    Summary:
+      Updated
+    Revision:
+      missingh--head--0.7--patch-173
+
+
+    modified files:
+     ChangeLog libsrc/MissingH/Time.hs testsrc/Timetest.hs
+
+
 2005-01-21 01:15:10 GMT	John Goerzen <jgoerzen at complete.org>	patch-172
 
     Summary:
diff --git a/libsrc/MissingH/Time.hs b/libsrc/MissingH/Time.hs
index f94984a..cd44bfe 100644
--- a/libsrc/MissingH/Time.hs
+++ b/libsrc/MissingH/Time.hs
@@ -34,6 +34,7 @@ Written by John Goerzen, jgoerzen\@complete.org
 
 module MissingH.Time(
                      calendarTimeUTCToEpoch,
+                     calendarTimeToEpoch,
                      timeDiffToSecs
                     )
 where
@@ -59,6 +60,20 @@ since effectively it is computing a difference. -}
 calendarTimeUTCToEpoch :: CalendarTime -> Integer
 calendarTimeUTCToEpoch ct =
     timeDiffToSecs (diffClockTimes (toClockTime ct) (toClockTime epoch))
+
+{- | Like 'calendarTimeUTCToEpoch', but works on local times.
+
+Caveat: may be inaccurate right around the change to/from DST.
+
+Ignores same fields as 'calendarTimeUTCToEpoch'.
+-}
+
+calendarTimeToEpoch :: CalendarTime -> IO Integer
+calendarTimeToEpoch ct =
+    do guessct <- toCalendarTime guesscl
+       let newct = ct {ctTZ = ctTZ guessct}
+       return $ calendarTimeUTCToEpoch newct
+    where guesscl = toClockTime ct
     
 {- | Converts the given timeDiff to the number of seconds it represents. 
 
diff --git a/testsrc/Timetest.hs b/testsrc/Timetest.hs
index 10b1a95..f4ff878 100644
--- a/testsrc/Timetest.hs
+++ b/testsrc/Timetest.hs
@@ -25,14 +25,32 @@ base =CalendarTime {ctYear = 2005, ctMonth = January, ctDay = 21,
                           ctHour = 1, ctMin = 1, ctSec = 20,
                           ctPicosec = 0, ctWDay = Sunday, ctYDay = 0,
                           ctTZName = "", ctTZ = 0, ctIsDST = False}
-test_ct2e =
+test_ctu2e =
     let f base exp = TestLabel (show base) $ TestCase $ exp @=? calendarTimeUTCToEpoch base in
         [
          f (base {ctYear = 2005, ctMonth = January, ctDay = 21,
                           ctHour = 1, ctMin = 1, ctSec = 20})
            1106269280
+           
+         ,f (base {ctYear = 2004, ctMonth = July, ctDay = 1,
+                           ctHour = 17, ctMin = 0, ctSec = 0})
+           1088701200
+
+        ]
 
+test_ct2e =
+    let f base exp = TestLabel (show base) $ TestCase $ 
+                       do r <- calendarTimeToEpoch base
+                          exp @=? r in
+        [
+         f (base {ctYear = 2005, ctMonth = January, ctDay = 20,
+                          ctHour = 19, ctMin = 1, ctSec = 20})
+           1106269280
+        ,f (base {ctYear = 2004, ctMonth = July, ctDay = 1,
+                           ctHour = 12, ctMin = 0, ctSec = 0})
+           1088701200
         ]
 
-tests = TestList [TestLabel "ct2e" (TestList test_ct2e)
+tests = TestList [TestLabel "ctu2e" (TestList test_ctu2e),
+                  TestLabel "ct2e" (TestList test_ct2e)
                  ]
\ No newline at end of file

-- 
haskell-testpack



More information about the Pkg-haskell-commits mailing list