+ -- The typechecker flips out without this.
+ isJustInt :: Maybe Int -> Bool
+ isJustInt = isJust
+
+ created_at_field = pack "created_at"
+ id_field = pack "id"
+ in_reply_to_status_id_field = pack "in_reply_to_status_id"
+ retweeted_field = pack "retweeted"
+ text_field = pack "text"
+ user_field = pack "user"
+
+ -- Do whatever.
+ parseJSON _ = mempty
+
+parse_status_time :: String -> Maybe UTCTime
+parse_status_time =
+ parseTime defaultTimeLocale status_format
+ where
+ -- | Should match e.g. "Sun Oct 24 18:21:41 +0000 2010"
+ status_format :: String
+ status_format = "%a %b %d %H:%M:%S %z %Y"
+
+utc_time_to_rfc822 :: Maybe TimeZone -> UTCTime -> String
+utc_time_to_rfc822 mtz utc =
+ case mtz of
+ Nothing -> foo utc
+ Just tz -> foo $ utcToZonedTime tz utc
+ where
+ foo = formatTime defaultTimeLocale rfc822DateFormat
+
+
+show_created_at :: Maybe TimeZone -> Status -> String
+show_created_at mtz =
+ (fromMaybe "") . (fmap $ utc_time_to_rfc822 mtz) . created_at
+
+-- | Returns a nicely-formatted String representing the given 'Status'
+-- object.
+pretty_print :: Maybe TimeZone -> Status -> String
+pretty_print mtz status =
+ concat [ name,
+ " - ",
+ sca,
+ "\n",
+ replicate bar_length '-',
+ "\n",
+ text status,
+ "\n\n",
+ join "\n" user_timeline_urls,
+ "\n" ]
+ where
+ sca = show_created_at mtz status
+ name = screen_name (user status)
+ user_timeline_urls = listify (make_user_timeline_urls status)
+ bar_length = (length name) + 3 + (length sca)