- status_ids = (unique_id content)
- first_status_id = get_char_data (status_ids !! 0)
-
- created_ats = (status_created_at content)
- first_created_at = get_char_data (created_ats !! 0)
-
- texts = (status_text content)
- all_text = concat $ catMaybes (map get_char_data texts)
-
- users = (status_user content)
- first_user = user_from_content (users !! 0)
-
-
--- |Takes an XML String as an argument, and returns the
--- status that was parsed from it. Should only be used
--- on XML string where a <status> is a top-level element.
-parse_status :: String -> [Status]
-parse_status xml_data =
- catMaybes maybe_status
- where
- (Document _ _ root _) = xmlParse xml_file_name xml_data
- root_elem = CElem root noPos
- status_element = (single_status root_elem)
- maybe_status = map status_from_content status_element
+ -- 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)