{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module TextShow.System.Time () where
import System.IO.Unsafe (unsafePerformIO)
import System.Time (ClockTime, TimeDiff, CalendarTime, Month, Day,
calendarTimeToString, toCalendarTime)
import TextShow (TextShow(..), fromString)
import TextShow.TH (deriveTextShow)
instance TextShow ClockTime where
showb :: ClockTime -> Builder
showb = String -> Builder
fromString (String -> Builder)
-> (ClockTime -> String) -> ClockTime -> Builder
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CalendarTime -> String
calendarTimeToString (CalendarTime -> String)
-> (ClockTime -> CalendarTime) -> ClockTime -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IO CalendarTime -> CalendarTime
forall a. IO a -> a
unsafePerformIO (IO CalendarTime -> CalendarTime)
-> (ClockTime -> IO CalendarTime) -> ClockTime -> CalendarTime
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ClockTime -> IO CalendarTime
toCalendarTime
$(deriveTextShow ''TimeDiff)
$(deriveTextShow ''Month)
$(deriveTextShow ''Day)
$(deriveTextShow ''CalendarTime)