X-Git-Url: http://gitweb.michael.orlitzky.com/?p=dead%2Fhalcyon.git;a=blobdiff_plain;f=src%2FTwitter%2FStatus.hs;fp=src%2FTwitter%2FStatus.hs;h=ba27d527d44f14ceeb3c6766e326d24d8beae501;hp=506a2c0bbe26ff67a561e7eee6b2e73d0629fb9f;hb=1b72ed45ef890ed1329a32457b4d7f3a7fb37788;hpb=0ed071e75268da9ba8273d5c13817fa1297c94e2 diff --git a/src/Twitter/Status.hs b/src/Twitter/Status.hs index 506a2c0..ba27d52 100644 --- a/src/Twitter/Status.hs +++ b/src/Twitter/Status.hs @@ -36,8 +36,8 @@ data Status = Status { reply :: Bool, retweeted :: Bool, text :: String, - user :: User - } deriving (Show, Eq) + user :: User } + deriving (Eq, Show) type Timeline = [Status] @@ -65,6 +65,8 @@ instance FromJSON Status where -- Do whatever. parseJSON _ = mempty +-- | Parse a timestamp from a status into a UTCTime (or Nothing). +-- parse_status_time :: String -> Maybe UTCTime parse_status_time = parseTime defaultTimeLocale status_format @@ -73,6 +75,10 @@ parse_status_time = status_format :: String status_format = "%a %b %d %H:%M:%S %z %Y" + +-- | Given a 'TimeZone', convert a 'UTCTime' into an RFC822-format +-- time string. If no 'TimeZone' is given, assume UTC. +-- utc_time_to_rfc822 :: Maybe TimeZone -> UTCTime -> String utc_time_to_rfc822 mtz utc = case mtz of @@ -82,10 +88,15 @@ utc_time_to_rfc822 mtz utc = foo = formatTime defaultTimeLocale rfc822DateFormat +-- | Get the 'created_at' time out of a 'Status' and display it as an +-- RFC822-format time string. If there's no created-at time in the +-- status, you'll get an empty string instead. +-- show_created_at :: Maybe TimeZone -> Status -> String show_created_at mtz = (maybe "" (utc_time_to_rfc822 mtz)) . created_at + -- | Returns a nicely-formatted String representing the given 'Status' -- object. --