- -- Should match e.g. "Sun Oct 24 18:21:41 +0000 2010"
- fmt :: String
- fmt = "%a %b %d %H:%M:%S %z %Y"
-
- reads_result :: [(ZonedTime, String)]
- reads_result = readsTime defaultTimeLocale fmt s
-
--- |Returns a nicely-formatted String representing the given 'Status'
--- object.
-pretty_print :: Status -> String
-pretty_print status =
- concat [ name,
- " - ",
- (created_at status),
- "\n",
- replicate ((length name) + 3 + (length (created_at status))) '-',
- "\n",
- replace_entities (text status),
- "\n\n",
- join "\n" user_timeline_urls,
- "\n" ]
- where
- name = screen_name (user status)
- user_timeline_urls = listify (make_user_timeline_urls status)
-
-
--- |Given a list of statuses, returns the greatest status_id belonging
--- to one of the statuses in the list.
-get_max_status_id :: [Status] -> Integer
+ 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.
+--
+-- >>> let u = User "washington_irving"
+-- >>> let created = parse_status_time "Sun Oct 24 18:21:41 +0000 2010"
+-- >>> let s = Status created 8675309 False False "IM TWITTERING" u
+-- >>> show_created_at Nothing s
+-- "Sun, 24 Oct 2010 18:21:41 UTC"
+-- >>> show_created_at Nothing s{ created_at = Nothing }
+-- ""
+--
+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.
+--
+-- Examples:
+--
+-- >>> let u = User "washington_irving"
+-- >>> let created = parse_status_time "Sun Oct 24 18:21:41 +0000 2010"
+-- >>> let s = Status created 8675309 False False "IM TWITTERING" u
+-- >>> putStr $ pretty_print Nothing s
+-- washington_irving - Sun, 24 Oct 2010 18:21:41 UTC
+-- -------------------------------------------------
+-- IM TWITTERING
+-- <BLANKLINE>
+-- <BLANKLINE>
+--
+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)
+
+
+-- | Given a list of statuses, returns the greatest status_id
+-- belonging to one of the statuses in the list.
+--
+-- Examples:
+--
+-- >>> let u = User "washington_irving"
+-- >>> let created = parse_status_time "Sun Oct 24 18:21:41 +0000 2010"
+-- >>> let s = Status created 8675309 False False "IM TWITTERING" u
+-- >>> let timeline = [s,s,s,s,s]
+-- >>> get_max_status_id timeline
+-- 8675309
+--
+get_max_status_id :: Timeline -> Integer