Skip to content

Commit

Permalink
Merge pull request #107 from tathougies/master
Browse files Browse the repository at this point in the history
Time 1.5 compatibility
  • Loading branch information
jaspervdj committed Feb 14, 2015
2 parents 3e048f5 + d7b48ab commit da58c67
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion digestive-functors/digestive-functors.cabal
Expand Up @@ -67,7 +67,8 @@ Library
mtl >= 1.1.0.0 && < 3,
old-locale >= 1.0 && < 1.1,
text >= 0.10 && < 1.3,
time >= 1.4 && < 1.5
time >= 1.4 && < 1.6
Extensions: CPP

Test-suite digestive-functors-tests
Type: exitcode-stdio-1.0
Expand Down
7 changes: 7 additions & 0 deletions digestive-functors/src/Text/Digestive/Form.hs
Expand Up @@ -3,6 +3,7 @@
{-# LANGUAGE GADTs #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE CPP #-}
-- | End-user interface - provides the main functionality for
-- form creation and validation. For an interface for front-end
-- implementation, see "View".
Expand Down Expand Up @@ -67,7 +68,9 @@ import Data.Maybe (fromMaybe)
import Data.Text (Text)
import qualified Data.Text as T
import Data.Time
#if !MIN_VERSION_time(1,5,0)
import System.Locale
#endif


--------------------------------------------------------------------------------
Expand Down Expand Up @@ -483,7 +486,11 @@ optionalTimeFormlet fmt d =

vFunc :: ParseTime a => String -> Text -> String -> Result Text a
vFunc fmt err x
#if MIN_VERSION_time(1,5,0)
| length x < 40 = maybe (Error err) Success $ parseTimeM True defaultTimeLocale fmt x
#else
| length x < 40 = maybe (Error err) Success $ parseTime defaultTimeLocale fmt x
#endif
| otherwise = Error "Not a valid date/time string"


Expand Down

0 comments on commit da58c67

Please sign in to comment.