将String转换为UTCTime类型

Lev*_*ell 6 haskell types

我正在编写一个getSitemapR使用yesod-sitemap生成站点地图文件的处理程序.我遇到的问题是将a String转换UTCTime为定义中的Data.Time.Clock.haddock文档说这UTCTimeRead类型类的一个实例,所以这就是我正在尝试的.这是我的代码.

module Handler.Root where

import Import
import Yesod.Goodies.Gravatar
import Data.Time.Format
import System.Locale
-- This is a handler function for the GET request method on the RootR
-- resource pattern. All of your resource patterns are defined in
-- config/routes
--
-- The majority of the code you will write in Yesod lives in these handler
-- functions. You can spread them across multiple files if you are so
-- inclined, or create a single monolithic file.
getRootR :: Handler RepHtml
getRootR = do
    defaultLayout $ do
        h2id <- lift newIdent
        setTitle "Cloudrr homepage"
        $(widgetFile "homepage")

gravatar :: Text -> String
gravatar email = 
  gravatarImg email go
  where
    go = GravatarOptions {
      gSize = Just (Size 140)
      , gDefault = Just (Identicon)
      , gForceDefault = ForceDefault False
      , gRating = Just (PG)
      }

getSitemapR :: Handler RepXml
getSitemapR = do
  sitemap [smo RootR]
  where
    smo = SitemapUrl  SitemapR{
      sitemapLoc = "http://www.cloudrr.me/sitemap.xml"
      , sitemapLastMod = (read "2011-11-19 18:28:r52.607875 UTC")::UTCTime
      , sitemapChangeFreq = Weekly
      , priority = 0.7
      }
Run Code Online (Sandbox Code Playgroud)

我在第20章关于系统编程的内容中查看了我的Real World Haskell副本,但它没有涵盖UTCTime它的代码示例,我搜索了谷歌的术语'haskell'将字符串转换为UTCTime"'没有结果.我在haskell-cafe邮件列表中找到了以下Thread,但由于SitemapLastMod没有使用,因此无法使用Maybe UTCTime.我想我在这里犯了一个非常愚蠢的错误,但我不确定,有人可以指点我正确的方向吗?

感谢您的时间和考虑.

dav*_*420 7

, sitemapLastMod = (read "2011-11-19 18:28:r52.607875 UTC")::UTCTime
Run Code Online (Sandbox Code Playgroud)

小写r不应该在那里.尝试

, sitemapLastMod = (read "2011-11-19 18:28:52.607875 UTC")::UTCTime
Run Code Online (Sandbox Code Playgroud)