Report a paste

Please put a quick comment for the admin.

If it looks like spam, the admin will mark it as spam so that the spam filter picks it up in the future.

If the paste contains something private or offensive, it'll probably just be deleted.

No title

class DateWidgetable a where
  toDateWidget :: a -> DateWidget 
  toDateWidgetFull :: a -> DateWidget 

instance DateWidgetable DepartureTime where
  toDateWidget dt = toDateWidget' False dt
  toDateWidgetFull dt = toDateWidget' True dt

toDateWidget' :: Bool -> DepartureTime -> DateWidget
toDateWidget' isFull (DayOnly day) = DateWidget (dayString isFull day) (dateString day) ""
toDateWidget' isFull (DayWithTime lt) = DateWidget (dayString isFull lt) (dateString lt) (timeString lt)
dayString :: (FormatTime a) => Bool -> a -> String
dayString isFull = formatTime defaultTimeLocale (if isFull then "%A" else "%a")
dateString :: (FormatTime a) => a -> String
dateString = formatTime defaultTimeLocale "%e %b"
timeString :: LocalTime -> String
timeString = formatTime defaultTimeLocale "%I %M %p"