
Thanks guys! Didn't expect this much help so fast, great community! I think my main problem was that I was constantly trying to print the result for my formatted date string which was of type IO String (at some point) I just learned that to print IO you need to bind it something like this main = getFormattedDate >>= putStrLn Thanks a lot, You rock!
On Nov 10, 2016, at 20:23, David McBride
wrote: It looks like you are trying to get time in UTC, then figuring out what date it is? You should be able to get the answer you are looking for with
getFormattedDate = do utc <- getCurrentTime return $ formatTime defaultTimeLocale "%m/%d/%Y" utc
Just keep in mind that that is the date in UTC. Not in your local time zone and it ignores daylight savings time. To get it in your time you'll have to replace getCurrentTime with getZonedTime.
On Thu, Nov 10, 2016 at 1:44 PM, sasa bogicevic
wrote: Hi All, This is a small program
{-# LANGUAGE OverloadedStrings #-} module Main where
import Control.Monad.IO.Class (liftIO) import qualified Data.ByteString.Lazy.Char8 as L import Data.Time import Network (withSocketsDo) import Network.HTTP.Conduit
createRequestData today = [("index:brKursneListe",""), ("index:year","2016"), ("index:inputCalendar1", today), ("index:vrsta","3"), ("index:prikaz","0"), ("index:buttonShow","Prikazi")]
timeFromString s = parseTimeOrError True defaultTimeLocale "%d %b %Y %l:%M %p" s
formatDateString time = formatTime defaultTimeLocale "%m/%d/%Y" time
getDateString = getCurrentTime
getFormatedDate = formatDateString $ timeFromString getDateString
main = do print $ getFormatedDate
And here is my error
main.hs:25:54: error: • Couldn't match type ‘IO UTCTime’ with ‘[Char]’ Expected type: String Actual type: IO UTCTime • In the first argument of ‘timeFromString’, namely ‘getDateString’ In the second argument of ‘($)’, namely ‘timeFromString getDateString’ In the expression: formatDateString $ timeFromString getDateString
Thanks!
_______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners