module Formatting.Time where
import Formatting.Holey
import Data.Text (Text)
import qualified Data.Text as T
import Data.Text.Buildable
import Data.Time
import System.Locale
tz :: FormatTime a => Format a
tz = later (build . fmt "%z")
tzName :: FormatTime a => Format a
tzName = later (build . fmt "%Z")
datetime :: FormatTime a => Format a
datetime = later (build . fmt "%c")
hm :: FormatTime a => Format a
hm = later (build . fmt "%R")
hms :: FormatTime a => Format a
hms = later (build . fmt "%T")
hmsL :: FormatTime a => Format a
hmsL = later (build . fmt "%X")
hmsPL :: FormatTime a => Format a
hmsPL = later (build . fmt "%r")
dayHalf :: FormatTime a => Format a
dayHalf = later (build . fmt "%P")
dayHalfU :: FormatTime a => Format a
dayHalfU = later (build . fmt "%p")
hour24 :: FormatTime a => Format a
hour24 = later (build . fmt "%H")
hour12 :: FormatTime a => Format a
hour12 = later (build . fmt "%I")
hour24S :: FormatTime a => Format a
hour24S = later (build . fmt "%k")
hour12S :: FormatTime a => Format a
hour12S = later (build . fmt "%l")
minute :: FormatTime a => Format a
minute = later (build . fmt "%M")
second :: FormatTime a => Format a
second = later (build . fmt "%S")
pico :: FormatTime a => Format a
pico = later (build . fmt "%q")
decimals :: FormatTime a => Format a
decimals = later (build . fmt "%Q")
epoch :: FormatTime a => Format a
epoch = later (build . fmt "%s")
dateSlash :: FormatTime a => Format a
dateSlash = later (build . fmt "%D")
dateDash :: FormatTime a => Format a
dateDash = later (build . fmt "%F")
dateSlashL :: FormatTime a => Format a
dateSlashL = later (build . fmt "%x")
year :: FormatTime a => Format a
year = later (build . fmt "%Y")
yy :: FormatTime a => Format a
yy = later (build . fmt "%y")
century :: FormatTime a => Format a
century = later (build . fmt "%C")
monthName :: FormatTime a => Format a
monthName = later (build . fmt "%B")
monthNameShort :: FormatTime a => Format a
monthNameShort = later (build . fmt "%b")
month :: FormatTime a => Format a
month = later (build . fmt "%m")
dayOfMonth :: FormatTime a => Format a
dayOfMonth = later (build . fmt "%d")
dayOfMonthS :: FormatTime a => Format a
dayOfMonthS = later (build . fmt "%e")
day :: FormatTime a => Format a
day = later (build . fmt "%j")
weekYear :: FormatTime a => Format a
weekYear = later (build . fmt "%G")
weekYY :: FormatTime a => Format a
weekYY = later (build . fmt "%g")
weekCentury :: FormatTime a => Format a
weekCentury = later (build . fmt "%f")
week :: FormatTime a => Format a
week = later (build . fmt "%V")
dayOfWeek :: FormatTime a => Format a
dayOfWeek = later (build . fmt "%u")
dayNameShort :: FormatTime a => Format a
dayNameShort = later (build . fmt "%a")
dayName :: FormatTime a => Format a
dayName = later (build . fmt "%A")
weekFromZero :: FormatTime a => Format a
weekFromZero = later (build . fmt "%U")
dayOfWeekFromZero :: FormatTime a => Format a
dayOfWeekFromZero = later (build . fmt "%w")
weekOfYearMon :: FormatTime a => Format a
weekOfYearMon = later (build . fmt "%W")
fmt :: FormatTime a => Text -> a -> Text
fmt f = T.pack . formatTime defaultTimeLocale (T.unpack f)