MissingH 1.3.0.2 → 1.4.0.0
raw patch · 29 files changed
+28/−455 lines, 29 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Data.Hash.CRC32.Posix: calc_crc32 :: [Char] -> Word32 -> Word32 -> Word32
- Data.Hash.CRC32.Posix: crc32 :: [Char] -> Word32
- Data.Hash.CRC32.Posix: crctab :: Array Int Word32
- Data.Hash.CRC32.Posix: iter_crc32 :: Word32 -> Char -> Word32
- System.Time.ParseDate: parseCalendarTime :: TimeLocale -> String -> String -> Maybe CalendarTime
Files
- LICENSE +0/−18
- MissingH.cabal +3/−4
- src/Control/Concurrent/Thread/Utils.hs +1/−0
- src/Data/BinPacking.hs +1/−0
- src/Data/Bits/Utils.hs +1/−0
- src/Data/CSV.hs +1/−0
- src/Data/Compression/Inflate.hs +1/−0
- src/Data/Either/Utils.hs +2/−1
- src/Data/Hash/CRC32/GZip.hs +1/−0
- src/Data/Hash/CRC32/Posix.hs +0/−122
- src/Data/List/Utils.hs +1/−0
- src/Data/Map/Utils.hs +1/−0
- src/Data/Maybe/Utils.hs +1/−0
- src/Data/Progress/Tracker.hs +1/−0
- src/Data/Quantity.hs +1/−0
- src/Data/Tuple/Utils.hs +1/−0
- src/Network/Email/Mailbox.hs +1/−0
- src/System/Console/GetOpt/Utils.hs +1/−0
- src/System/FileArchive/GZip.hs +1/−0
- src/System/IO/HVIO.hs +1/−0
- src/System/IO/PlafCompat.hs +1/−0
- src/System/IO/StatCompat.hs +1/−0
- src/System/IO/WindowsCompat.hs +1/−0
- src/System/Path/NameManip.hs +1/−0
- src/System/Posix/Consts.hs +1/−0
- src/System/Time/ParseDate.hs +0/−284
- src/System/Time/Utils.hs +1/−0
- src/Text/ParserCombinators/Parsec/Utils.hs +1/−0
- testsrc/CRC32POSIXtest.hs +0/−26
LICENSE view
@@ -42,15 +42,6 @@ BSD license as MissingH itself. -----------------------------------------------------Data.Hash.CRC32.Posix is-(C) 2002 HardCore SoftWare, Doug Hoyte-and is "distributed under the terms of the GNU GPL." This license is-the same as the main license for MissingH.--The code was obtained from -http://cvs.sourceforge.net/viewcvs.py/haskell-libs/libs/crypto/crc32.hs------------------------------------------------------ Data.Compression.Inflate is Copyright 2004 Ian Lynagh <igloo@earth.li> Licence: 3 clause BSD.@@ -77,12 +68,3 @@ The code was obtained from http://web.comlab.ox.ac.uk/oucl/work/ian.lynagh/md5/ ------------------------------------------------------System.Time.Utils.ParseDate is from -http://www.dtek.chalmers.se/~d00bring/projects.html--Copyright (c) Bj<F6>rn Bringert-License: GNU General Public License, version 2--I (John Goerzen) have modified only the module name and Haddock-comments at the top of it.
MissingH.cabal view
@@ -1,5 +1,5 @@ Name: MissingH-Version: 1.3.0.2+Version: 1.4.0.0 License: BSD3 Maintainer: John Goerzen <jgoerzen@complete.org> Author: John Goerzen@@ -59,14 +59,14 @@ Data.Quantity, Data.Map.Utils, System.Path, System.Path.NameManip, System.Path.WildMatch, System.Path.Glob,- System.Time.Utils, System.Time.ParseDate,+ System.Time.Utils, Network.Utils, Network.SocketServer, Data.Either.Utils, Data.Maybe.Utils, Data.Tuple.Utils, Data.Bits.Utils,- Data.Hash.CRC32.Posix, Data.Hash.CRC32.GZip,+ Data.Hash.CRC32.GZip, Data.Hash.MD5, Data.Hash.MD5.Zord64_HARD, Data.Compression.Inflate, System.FileArchive.GZip,@@ -118,7 +118,6 @@ HS-Source-Dirs: testsrc, ., src Other-Modules: Bitstest, CRC32GZIPtest,- CRC32POSIXtest, Eithertest, GZiptest, Globtest,
src/Control/Concurrent/Thread/Utils.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE Safe #-} {- arch-tag: Thread utilities main file Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
src/Data/BinPacking.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE Safe #-} {- Copyright (c) 2008-2011 John Goerzen <jgoerzen@complete.org>
src/Data/Bits/Utils.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE Safe #-} {- arch-tag: Bit utilities main file Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
src/Data/CSV.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE Safe #-} {- arch-tag: CSV and TSV utilities Copyright (c) 2005-2011 John Goerzen <jgoerzen@complete.org>
src/Data/Compression/Inflate.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE Safe #-} -- arch-tag: Inflate implementation for Haskell {-
src/Data/Either/Utils.hs view
@@ -1,4 +1,5 @@-{- arch-tag: Euither utilities+{-# LANGUAGE Safe #-}+{- arch-tag: Either utilities Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org> All rights reserved.
src/Data/Hash/CRC32/GZip.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE Safe #-} {- arch-tag: GZIP CRC32 implementation in pure Haskell Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
− src/Data/Hash/CRC32/Posix.hs
@@ -1,122 +0,0 @@--- arch-tag: CRC32 implementation in pure Haskell--- from http://cvs.sourceforge.net/viewcvs.py/haskell-libs/libs/crypto/crc32.hs------ crc32.hs (C) 2002 HardCore SoftWare, Doug Hoyte------ This program is distributed under the terms of the GNU GPL.--- See www.gnu.org for more information. ------ Haskell implementation of the 32-bit Cyclic Redundancy Check.--- This code was modeled after the cksum utility distributed with--- OpenBSD - the lookup table was in fact lifted from the OpenBSD--- implementation.------ Once compiled, this program is almost a drop-in replacement for--- the OpenBSD cksum utility.---- $Id: crc32.hs,v 1.2 2003/03/24 00:08:55 eris Exp $ --{- |- Module : Data.Hash.CRC32.Posix- Copyright : Copyright (C) 2002 HardCore SoftWare, Doug Hoyte- License : GNU GPL-- Maintainer : John Goerzen <jgoerzen@complete.org> - Stability : provisional- Portability: portable--CRC32 checksumming using POSIX 1003.2-1992 algorithm for the polynomial { 32 26-23 22 16 12 11 10 8 7 5 4 2 1 }, also defined in ISO 8802-3: 1989.--Copyright (c) 2002 HardCore SoftWare, Doug Hoyte--}--{--Modified December, 2004 by John Goerzen:- * Integrate with MissingH- * Removed code we don't need in a library- * Updated things that didn't compile any more--}--module Data.Hash.CRC32.Posix where--import Data.Array-import Data.Bits-import Data.Word--iter_crc32 :: Word32 -> Char -> Word32-iter_crc32 sumval ch = (sumval `shiftL` 8) `xor`- crctab ! fromIntegral ((sumval `shiftR` 24) `xor`- (fromIntegral (fromEnum ch)))---calc_crc32 :: [Char] -> Word32 -> Word32 -> Word32-calc_crc32 [] ck 0 = ck `xor` 0xFFFFFFFF-calc_crc32 [] ck l = calc_crc32- []- (iter_crc32 ck (toEnum $ fromIntegral (l .&. 0xFF)))- (l `shiftR` 8)-calc_crc32 (x:xs) ck l = calc_crc32 xs (iter_crc32 ck x) (l+1)---crc32 :: [Char] -> Word32-crc32 x = calc_crc32 x 0 0---crctab :: Array Int Word32-crctab = array (0,255) (zip [0..255]- [- 0x0,- 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b,- 0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6,- 0x2b4bcb61, 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd,- 0x4c11db70, 0x48d0c6c7, 0x4593e01e, 0x4152fda9, 0x5f15adac,- 0x5bd4b01b, 0x569796c2, 0x52568b75, 0x6a1936c8, 0x6ed82b7f,- 0x639b0da6, 0x675a1011, 0x791d4014, 0x7ddc5da3, 0x709f7b7a,- 0x745e66cd, 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039,- 0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5, 0xbe2b5b58,- 0xbaea46ef, 0xb7a96036, 0xb3687d81, 0xad2f2d84, 0xa9ee3033,- 0xa4ad16ea, 0xa06c0b5d, 0xd4326d90, 0xd0f37027, 0xddb056fe,- 0xd9714b49, 0xc7361b4c, 0xc3f706fb, 0xceb42022, 0xca753d95,- 0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1, 0xe13ef6f4,- 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d, 0x34867077, 0x30476dc0,- 0x3d044b19, 0x39c556ae, 0x278206ab, 0x23431b1c, 0x2e003dc5,- 0x2ac12072, 0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16,- 0x018aeb13, 0x054bf6a4, 0x0808d07d, 0x0cc9cdca, 0x7897ab07,- 0x7c56b6b0, 0x71159069, 0x75d48dde, 0x6b93dddb, 0x6f52c06c,- 0x6211e6b5, 0x66d0fb02, 0x5e9f46bf, 0x5a5e5b08, 0x571d7dd1,- 0x53dc6066, 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba,- 0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, 0xbfa1b04b,- 0xbb60adfc, 0xb6238b25, 0xb2e29692, 0x8aad2b2f, 0x8e6c3698,- 0x832f1041, 0x87ee0df6, 0x99a95df3, 0x9d684044, 0x902b669d,- 0x94ea7b2a, 0xe0b41de7, 0xe4750050, 0xe9362689, 0xedf73b3e,- 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2, 0xc6bcf05f,- 0xc27dede8, 0xcf3ecb31, 0xcbffd686, 0xd5b88683, 0xd1799b34,- 0xdc3abded, 0xd8fba05a, 0x690ce0ee, 0x6dcdfd59, 0x608edb80,- 0x644fc637, 0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb,- 0x4f040d56, 0x4bc510e1, 0x46863638, 0x42472b8f, 0x5c007b8a,- 0x58c1663d, 0x558240e4, 0x51435d53, 0x251d3b9e, 0x21dc2629,- 0x2c9f00f0, 0x285e1d47, 0x36194d42, 0x32d850f5, 0x3f9b762c,- 0x3b5a6b9b, 0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff,- 0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623, 0xf12f560e,- 0xf5ee4bb9, 0xf8ad6d60, 0xfc6c70d7, 0xe22b20d2, 0xe6ea3d65,- 0xeba91bbc, 0xef68060b, 0xd727bbb6, 0xd3e6a601, 0xdea580d8,- 0xda649d6f, 0xc423cd6a, 0xc0e2d0dd, 0xcda1f604, 0xc960ebb3,- 0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7, 0xae3afba2,- 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b, 0x9b3660c6, 0x9ff77d71,- 0x92b45ba8, 0x9675461f, 0x8832161a, 0x8cf30bad, 0x81b02d74,- 0x857130c3, 0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640,- 0x4e8ee645, 0x4a4ffbf2, 0x470cdd2b, 0x43cdc09c, 0x7b827d21,- 0x7f436096, 0x7200464f, 0x76c15bf8, 0x68860bfd, 0x6c47164a,- 0x61043093, 0x65c52d24, 0x119b4be9, 0x155a565e, 0x18197087,- 0x1cd86d30, 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec,- 0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, 0x2497d08d,- 0x2056cd3a, 0x2d15ebe3, 0x29d4f654, 0xc5a92679, 0xc1683bce,- 0xcc2b1d17, 0xc8ea00a0, 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb,- 0xdbee767c, 0xe3a1cbc1, 0xe760d676, 0xea23f0af, 0xeee2ed18,- 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4, 0x89b8fd09,- 0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5, 0x9e7d9662,- 0x933eb0bb, 0x97ffad0c, 0xafb010b1, 0xab710d06, 0xa6322bdf,- 0xa2f33668, 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4- ])-
src/Data/List/Utils.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE Safe #-} {- arch-tag: List utilities main file Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
src/Data/Map/Utils.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE Safe #-} {- Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
src/Data/Maybe/Utils.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE Safe #-} {- arch-tag: Maybe utilities Copyright (c) 2005-2011 John Goerzen <jgoerzen@complete.org>
src/Data/Progress/Tracker.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE Safe #-} {- Copyright (c) 2006-2011 John Goerzen <jgoerzen@complete.org>
src/Data/Quantity.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE Safe #-} {- Copyright (c) 2006-2011 John Goerzen <jgoerzen@complete.org>
src/Data/Tuple/Utils.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE Safe #-} {- arch-tag: Tuple utilities main file Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
src/Network/Email/Mailbox.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE Safe #-} {- Copyright (c) 2005-2011 John Goerzen <jgoerzen@complete.org>
src/System/Console/GetOpt/Utils.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE Safe #-} {- Copyright (c) 2005-2011 John Goerzen <jgoerzen@complete.org>
src/System/FileArchive/GZip.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE Safe #-} {- arch-tag: GZip file support in Haskell Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
src/System/IO/HVIO.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE Safe #-} {- arch-tag: HVIO main file Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
src/System/IO/PlafCompat.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-}+{-# LANGUAGE Safe #-} {- Platform Compatibility Layer Copyright (c) 2005-2011 John Goerzen <jgoerzen@complete.org>
src/System/IO/StatCompat.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-}+{-# LANGUAGE Safe #-} {- Copyright (c) 2005-2011 John Goerzen <jgoerzen@complete.org>
src/System/IO/WindowsCompat.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-}+{-# LANGUAGE Safe #-} {- Windows compatibility layer Copyright (c) 2005-2011 John Goerzen <jgoerzen@complete.org>
src/System/Path/NameManip.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE Safe #-} {- | Module : System.Path.NameManip Copyright : Copyright (C) 2004 Volker Wysk
src/System/Posix/Consts.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-}+{-# LANGUAGE Safe #-} {- Posix consts not included with Haskell Copyright (c) 2005-2011 John Goerzen <jgoerzen@complete.org>
− src/System/Time/ParseDate.hs
@@ -1,284 +0,0 @@-{- |- Module : System.Time.ParseDate- Copyright : (c) by Björn Bringert- License : GPL2-- Maintainer : Björn Bringert- Stability : provisional- Portability : portable--Utility for parsing dates.--}-module System.Time.ParseDate (parseCalendarTime) where--import Control.Monad (liftM)-import Data.Char (isSpace)-import System.Locale-import System.Time-import Text.ParserCombinators.Parsec--{- | Parse a date string as formatted by 'formatCalendarTime'.-- The resulting 'CalendarTime' will only have those fields set that- are represented by a format specifier in the format string, and those- fields will be set to the values given in the date string.- If the same field is specified multiple times, the rightmost- occurence takes precedence.-- The resulting date is not neccessarily a valid date. For example,- if there is no day of the week specifier in the format string,- the value of 'ctWDay' will most likely be invalid.-- Format specifiers are % followed by some character. All other- characters are treated literally. Whitespace in the format string- matches zero or more arbitrary whitespace characters.-- Format specifiers marked with * are matched, but do not set any- field in the output.-- Some of the format specifiers are marked as space-padded or- zero-padded. Regardless of this, space-padded, zero-padded- or unpadded inputs are accepted. Note that strings using- unpadded fields without separating the fields may cause- strange parsing.-- Supported format specfiers:-- [%%] a % character.-- [%a] locale's abbreviated weekday name (Sun ... Sat)-- [%A] locale's full weekday name (Sunday .. Saturday)-- [%b] locale's abbreviated month name (Jan..Dec)-- [%B] locale's full month name (January..December)-- [%c] locale's date and time format (Thu Mar 25 17:47:03 CET 2004)-- [%C] century [00-99]-- [%d] day of month, zero padded (01..31)-- [%D] date (%m\/%d\/%y)-- [%e] day of month, space padded ( 1..31)-- [%h] same as %b-- [%H] hour, 24-hour clock, zero padded (00..23)-- [%I] hour, 12-hour clock, zero padded (01..12)-- [%j] day of the year, zero padded (001..366)-- [%k] hour, 24-hour clock, space padded ( 0..23)-- [%l] hour, 12-hour clock, space padded ( 1..12)-- [%m] month, zero padded (01..12)-- [%M] minute, zero padded (00..59)-- [%n] a newline character-- [%p] locale's AM or PM indicator-- [%r] locale's 12-hour time format (hh:mm:ss AM\/PM)-- [%R] hours and minutes, 24-hour clock (hh:mm)-- [%s] * seconds since '00:00:00 1970-01-01 UTC'-- [%S] seconds, zero padded (00..59)-- [%t] a horizontal tab character-- [%T] time, 24-hour clock (hh:mm:ss)-- [%u] numeric day of the week (1=Monday, 7=Sunday)-- [%U] * week number, weeks starting on Sunday, zero padded (01-53)-- [%V] * week number (as per ISO-8601),- week 1 is the first week with a Thursday,- zero padded, (01-53)-- [%w] numeric day of the week, (0=Sunday, 6=Monday)-- [%W] * week number, weeks starting on Monday, zero padded (01-53)-- [%x] locale's preferred way of printing dates (%m\/%d\/%y)-- [%X] locale's preferred way of printing time. (%H:%M:%S)-- [%y] year, within century, zero padded (00..99)-- [%Y] year, including century. Not padded- (this is probably a bug, but formatCalendarTime does- it this way). (0-9999)-- [%Z] time zone abbreviation (e.g. CET) or RFC-822 style numeric- timezone (-0500) -}-parseCalendarTime ::- TimeLocale -- ^ Time locale- -> String -- ^ Date format- -> String -- ^ String to parse- -> Maybe CalendarTime -- ^ 'Nothing' if parsing failed.-parseCalendarTime l fmt s =- case runParser parser epoch "<date string>" s of- Left _ -> Nothing- Right p -> Just p- where parser = pCalendarTime l fmt >> getState---- FIXME: verify input--- FIXME: years outside 1000-9999 probably don't work--- FIXME: what about extra whitespace in input?--- FIXME: set ctYDay--- FIXME: set ctIsDST--- FIXME: missing formats from GNU date(1):--- %F same as %Y-%m-%d--- %g the 2-digit year corresponding to the %V week number--- %G the 4-digit year corresponding to the %V week number--- %N nanoseconds (000000000..999999999)--- %P locale's lower case am or pm indicator (blank in many locales)--- %z RFC-822 style numeric timezone (-0500) (a nonstandard extension)-pCalendarTime :: TimeLocale -> String -> GenParser Char CalendarTime ()-pCalendarTime l fmt = doFmt fmt- where- -- not padded- -- FIXME: implement- doFmt ('%':'-':cs) = doFmt ('%':cs)- -- space padded- -- FIXME: implement- doFmt ('%':'_':cs) = doFmt ('%':cs)- doFmt ('%':c:cs) = decode c >> doFmt cs- doFmt (c:cs) = char c >> doFmt cs- doFmt "" = return ()-- decode '%' = char '%' >> return ()- decode 'a' = (parseEnum $ map snd $ wDays l) >>= setWDay- decode 'A' = (parseEnum $ map fst $ wDays l) >>= setWDay- decode 'b' = (parseEnum $ map snd $ months l) >>= setMonth- decode 'B' = (parseEnum $ map fst $ months l) >>= setMonth- decode 'c' = doFmt (dateTimeFmt l)- decode 'C' = read2 >>= \c -> updateYear (\y -> c * 100 + y `rem` 100)- decode 'd' = read2 >>= \day -> if day > 31 || day < 1- then fail $ "Invalid day " ++ (show day)- else setDay day- decode 'D' = doFmt "%m/%d/%y"- decode 'e' = read2 >>= setDay- decode 'h' = decode 'b'- decode 'H' = read2 >>= setHour- decode 'I' = read2 >>= setHour12- decode 'j' = read3 >>= setYDay- decode 'k' = read2 >>= setHour- decode 'l' = read2 >>= setHour12- decode 'm' = read2 >>= \mon -> if (mon-1) > fromEnum (maxBound :: Month)- then fail $ "Invalid month " ++ (show mon)- else setMonth (toEnum (mon-1))- decode 'M' = read2 >>= setMin- -- FIXME: strptime(3) accepts "arbitrary whitespace" for %n- decode 'n' = char '\n' >> return ()- decode 'p' = do- x <- (string am >> return 0) <|> (string pm >> return 12)- updateHour (\h -> x + h `rem` 12)- where (am,pm) = amPm l- decode 'r' = doFmt (time12Fmt l)- decode 'R' = doFmt "%H:%M"- -- FIXME: implement %s.- -- FIXME: implement %s in formatCalendarTime- decode 's' = int >> return ()- decode 'S' = read2 >>= setSec- -- FIXME: strptime(3) accepts "arbitrary whitespace" for %t- decode 't' = char '\t' >> return ()- decode 'T' = doFmt "%H:%M:%S"- decode 'u' = readN 1 >>= setWDay . toEnum . (\w -> if w == 7 then 0 else w)- -- FIXME: implement %U.- decode 'U' = read2 >> return ()- -- FIXME: implement %V.- decode 'V' = read2 >> return ()- decode 'w' = readN 1 >>= setWDay . toEnum- -- FIXME: implement %W.- decode 'W' = read2 >> return ()- decode 'x' = doFmt (dateFmt l)- decode 'X' = doFmt (timeFmt l)- -- FIXME: should probably be zero padded,- -- need to change formatCalendarTime too- decode 'Y' = int >>= setYear- -- FIXME: maybe 04 should be 2004, not 1904?- decode 'y' = read2 >>= \c -> updateYear (\y -> (y `quot` 100) * 100 + c)- -- FIXME: are timezone names always [A-Z]+ ?- -- FIXME: set ctTZ when parsing timezone name and- -- ctTZName when parsing offset- decode 'Z' = tzname <|> tzoffset- where tzname = many1 (oneOf ['A'..'Z']) >>= setTZName- tzoffset = do- s <- sign- h <- read2- m <- read2- setTZ (s * (h * 3600 + m * 60))- -- following the example of strptime(3),- -- whitespace matches zero or more whitespace- -- characters in the input string- decode c | isSpace c = spaces >> return ()- decode c = char c >> return ()--epoch :: CalendarTime-epoch = CalendarTime {- ctYear = 1970,- ctMonth = January,- ctDay = 1,- ctHour = 0,- ctMin = 0,- ctSec = 0,- ctPicosec = 0,- ctWDay = Thursday,- ctYDay = 1,- ctTZName = "UTC",- ctTZ = 0,- ctIsDST = False- }--parseEnum :: Enum a => [String] -> CharParser st a-parseEnum ss = choice (zipWith tryString ss (enumFrom (toEnum 0)))- where tryString s x = try (string s) >> return x--setYear,setDay,setHour,setHour12,setMin,setSec,setYDay,setTZ :: Int -> GenParser tok CalendarTime ()-setYear x = updateState (\t -> t{ ctYear = x })-setMonth :: Month -> GenParser tok CalendarTime ()-setMonth x = updateState (\t -> t{ ctMonth = x })-setDay x = updateState (\t -> t{ ctDay = x })-setHour x = updateState (\t -> t{ ctHour = x })-setMin x = updateState (\t -> t{ ctMin = x })-setSec x = updateState (\t -> t{ ctSec = x })-setWDay :: Day -> GenParser tok CalendarTime ()-setWDay x = updateState (\t -> t{ ctWDay = x })-setYDay x = updateState (\t -> t{ ctYDay = x })-setTZName :: String -> GenParser tok CalendarTime ()-setTZName x = updateState (\t -> t{ ctTZName = x })-setTZ x = updateState (\t -> t{ ctTZ = x })--updateYear :: (Int -> Int) -> GenParser tok CalendarTime ()-updateYear f = updateState (\t -> t{ ctYear = f (ctYear t) })-updateHour :: (Int -> Int) -> GenParser tok CalendarTime ()-updateHour f = updateState (\t -> t{ ctHour = f (ctHour t) })--setHour12 x = updateHour (\h -> (h `quot` 12) * 12 + from12 x)- where from12 h = if h == 12 then 0 else h--read2, read3 :: GenParser Char st Int-read2 = readN 2-read3 = readN 3---- | Read up to a given number of digits, optionally left-padded--- with whitespace and interpret them as an 'Int'.-readN :: Int -> GenParser Char st Int-readN n =- liftM read (spaces >> choice [try (count m digit) | m <- [n,n-1..1]])--int :: GenParser Char st Int-int = liftM read (many1 digit)--sign :: GenParser Char st Int-sign = (char '+' >> return 1) <|> (char '-' >> return (-1))
src/System/Time/Utils.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE Safe #-} {- arch-tag: Time utilities main file Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
src/Text/ParserCombinators/Parsec/Utils.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE Safe #-} {- arch-tag: Parsec utilities Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
− testsrc/CRC32POSIXtest.hs
@@ -1,26 +0,0 @@-{- arch-tag: Tests for CRC-32 module-Copyright (C) 2004-2011 John Goerzen <jgoerzen@complete.org>--All rights reserved.--For license and copyright information, see the file LICENSE--}--module CRC32POSIXtest(tests) where-import Test.HUnit-import Data.Hash.CRC32.Posix--test_crc32 =- let f msg inp exp = TestLabel msg $ TestCase $ assertEqual "" exp (crc32 inp) in- [- f "Empty" "" 4294967295,- f "1" "1" 433426081,- f "some numbers" "153141341309874102987412" 2083856642,- f "Some text" "This is a test of the crc32 thing\n" 2449124888-- ]--tests = TestList [TestLabel "crc32" (TestList test_crc32)-- ]-