{-# OPTIONS -fno-warn-orphans #-}
module Data.Time.Format.Format.Instances () where
import Data.Char
import Data.Fixed
import Data.Time.Clock.Internal.DiffTime
import Data.Time.Clock.Internal.NominalDiffTime
import Data.Time.Clock.Internal.UniversalTime
import Data.Time.Clock.Internal.UTCTime
import Data.Time.Clock.POSIX
import Data.Time.Calendar.Days
import Data.Time.Calendar.CalendarDiffDays
import Data.Time.Calendar.Gregorian
import Data.Time.Calendar.Week
import Data.Time.Calendar.WeekDate
import Data.Time.Calendar.OrdinalDate
import Data.Time.Calendar.Private
import Data.Time.LocalTime.Internal.CalendarDiffTime
import Data.Time.LocalTime.Internal.TimeZone
import Data.Time.LocalTime.Internal.TimeOfDay
import Data.Time.LocalTime.Internal.LocalTime
import Data.Time.LocalTime.Internal.ZonedTime
import Data.Time.Format.Locale
import Data.Time.Format.Format.Class
instance FormatTime LocalTime where
formatCharacter :: Bool -> Char -> Maybe (FormatOptions -> LocalTime -> String)
formatCharacter _ 'c' = (FormatOptions -> LocalTime -> String)
-> Maybe (FormatOptions -> LocalTime -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> LocalTime -> String)
-> Maybe (FormatOptions -> LocalTime -> String))
-> (FormatOptions -> LocalTime -> String)
-> Maybe (FormatOptions -> LocalTime -> String)
forall a b. (a -> b) -> a -> b
$ \fo :: FormatOptions
fo -> TimeLocale -> String -> LocalTime -> String
forall t. FormatTime t => TimeLocale -> String -> t -> String
formatTime (FormatOptions -> TimeLocale
foLocale FormatOptions
fo) (String -> LocalTime -> String) -> String -> LocalTime -> String
forall a b. (a -> b) -> a -> b
$ TimeLocale -> String
dateTimeFmt (TimeLocale -> String) -> TimeLocale -> String
forall a b. (a -> b) -> a -> b
$ FormatOptions -> TimeLocale
foLocale FormatOptions
fo
formatCharacter alt :: Bool
alt c :: Char
c = case Bool -> Char -> Maybe (FormatOptions -> Day -> String)
forall t.
FormatTime t =>
Bool -> Char -> Maybe (FormatOptions -> t -> String)
formatCharacter Bool
alt Char
c of
Just f :: FormatOptions -> Day -> String
f -> (FormatOptions -> LocalTime -> String)
-> Maybe (FormatOptions -> LocalTime -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> LocalTime -> String)
-> Maybe (FormatOptions -> LocalTime -> String))
-> (FormatOptions -> LocalTime -> String)
-> Maybe (FormatOptions -> LocalTime -> String)
forall a b. (a -> b) -> a -> b
$ \fo :: FormatOptions
fo dt :: LocalTime
dt -> FormatOptions -> Day -> String
f FormatOptions
fo (LocalTime -> Day
localDay LocalTime
dt)
Nothing -> case Bool -> Char -> Maybe (FormatOptions -> TimeOfDay -> String)
forall t.
FormatTime t =>
Bool -> Char -> Maybe (FormatOptions -> t -> String)
formatCharacter Bool
alt Char
c of
Just f :: FormatOptions -> TimeOfDay -> String
f -> (FormatOptions -> LocalTime -> String)
-> Maybe (FormatOptions -> LocalTime -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> LocalTime -> String)
-> Maybe (FormatOptions -> LocalTime -> String))
-> (FormatOptions -> LocalTime -> String)
-> Maybe (FormatOptions -> LocalTime -> String)
forall a b. (a -> b) -> a -> b
$ \fo :: FormatOptions
fo dt :: LocalTime
dt -> FormatOptions -> TimeOfDay -> String
f FormatOptions
fo (LocalTime -> TimeOfDay
localTimeOfDay LocalTime
dt)
Nothing -> Maybe (FormatOptions -> LocalTime -> String)
forall a. Maybe a
Nothing
todAMPM :: TimeLocale -> TimeOfDay -> String
todAMPM :: TimeLocale -> TimeOfDay -> String
todAMPM locale :: TimeLocale
locale day :: TimeOfDay
day = let
(am :: String
am,pm :: String
pm) = TimeLocale -> (String, String)
amPm TimeLocale
locale
in if (TimeOfDay -> Int
todHour TimeOfDay
day) Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< 12 then String
am else String
pm
tod12Hour :: TimeOfDay -> Int
tod12Hour :: TimeOfDay -> Int
tod12Hour day :: TimeOfDay
day = (Int -> Int -> Int
forall a. Integral a => a -> a -> a
mod (TimeOfDay -> Int
todHour TimeOfDay
day Int -> Int -> Int
forall a. Num a => a -> a -> a
- 1) 12) Int -> Int -> Int
forall a. Num a => a -> a -> a
+ 1
instance FormatTime TimeOfDay where
formatCharacter :: Bool -> Char -> Maybe (FormatOptions -> TimeOfDay -> String)
formatCharacter _ 'R' = (FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String))
-> (FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String)
forall a b. (a -> b) -> a -> b
$ (TimeLocale -> TimeOfDay -> String)
-> FormatOptions -> TimeOfDay -> String
forall t.
(TimeLocale -> t -> String) -> FormatOptions -> t -> String
formatString ((TimeLocale -> TimeOfDay -> String)
-> FormatOptions -> TimeOfDay -> String)
-> (TimeLocale -> TimeOfDay -> String)
-> FormatOptions
-> TimeOfDay
-> String
forall a b. (a -> b) -> a -> b
$ \locale :: TimeLocale
locale -> TimeLocale -> String -> TimeOfDay -> String
forall t. FormatTime t => TimeLocale -> String -> t -> String
formatTime TimeLocale
locale "%H:%M"
formatCharacter _ 'T' = (FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String))
-> (FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String)
forall a b. (a -> b) -> a -> b
$ (TimeLocale -> TimeOfDay -> String)
-> FormatOptions -> TimeOfDay -> String
forall t.
(TimeLocale -> t -> String) -> FormatOptions -> t -> String
formatString ((TimeLocale -> TimeOfDay -> String)
-> FormatOptions -> TimeOfDay -> String)
-> (TimeLocale -> TimeOfDay -> String)
-> FormatOptions
-> TimeOfDay
-> String
forall a b. (a -> b) -> a -> b
$ \locale :: TimeLocale
locale -> TimeLocale -> String -> TimeOfDay -> String
forall t. FormatTime t => TimeLocale -> String -> t -> String
formatTime TimeLocale
locale "%H:%M:%S"
formatCharacter _ 'X' = (FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String))
-> (FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String)
forall a b. (a -> b) -> a -> b
$ (TimeLocale -> TimeOfDay -> String)
-> FormatOptions -> TimeOfDay -> String
forall t.
(TimeLocale -> t -> String) -> FormatOptions -> t -> String
formatString ((TimeLocale -> TimeOfDay -> String)
-> FormatOptions -> TimeOfDay -> String)
-> (TimeLocale -> TimeOfDay -> String)
-> FormatOptions
-> TimeOfDay
-> String
forall a b. (a -> b) -> a -> b
$ \locale :: TimeLocale
locale -> TimeLocale -> String -> TimeOfDay -> String
forall t. FormatTime t => TimeLocale -> String -> t -> String
formatTime TimeLocale
locale (TimeLocale -> String
timeFmt TimeLocale
locale)
formatCharacter _ 'r' = (FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String))
-> (FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String)
forall a b. (a -> b) -> a -> b
$ (TimeLocale -> TimeOfDay -> String)
-> FormatOptions -> TimeOfDay -> String
forall t.
(TimeLocale -> t -> String) -> FormatOptions -> t -> String
formatString ((TimeLocale -> TimeOfDay -> String)
-> FormatOptions -> TimeOfDay -> String)
-> (TimeLocale -> TimeOfDay -> String)
-> FormatOptions
-> TimeOfDay
-> String
forall a b. (a -> b) -> a -> b
$ \locale :: TimeLocale
locale -> TimeLocale -> String -> TimeOfDay -> String
forall t. FormatTime t => TimeLocale -> String -> t -> String
formatTime TimeLocale
locale (TimeLocale -> String
time12Fmt TimeLocale
locale)
formatCharacter _ 'P' = (FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String))
-> (FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String)
forall a b. (a -> b) -> a -> b
$ (TimeLocale -> TimeOfDay -> String)
-> FormatOptions -> TimeOfDay -> String
forall t.
(TimeLocale -> t -> String) -> FormatOptions -> t -> String
formatString ((TimeLocale -> TimeOfDay -> String)
-> FormatOptions -> TimeOfDay -> String)
-> (TimeLocale -> TimeOfDay -> String)
-> FormatOptions
-> TimeOfDay
-> String
forall a b. (a -> b) -> a -> b
$ \locale :: TimeLocale
locale -> (Char -> Char) -> String -> String
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
toLower (String -> String) -> (TimeOfDay -> String) -> TimeOfDay -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TimeLocale -> TimeOfDay -> String
todAMPM TimeLocale
locale
formatCharacter _ 'p' = (FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String))
-> (FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String)
forall a b. (a -> b) -> a -> b
$ (TimeLocale -> TimeOfDay -> String)
-> FormatOptions -> TimeOfDay -> String
forall t.
(TimeLocale -> t -> String) -> FormatOptions -> t -> String
formatString ((TimeLocale -> TimeOfDay -> String)
-> FormatOptions -> TimeOfDay -> String)
-> (TimeLocale -> TimeOfDay -> String)
-> FormatOptions
-> TimeOfDay
-> String
forall a b. (a -> b) -> a -> b
$ \locale :: TimeLocale
locale -> TimeLocale -> TimeOfDay -> String
todAMPM TimeLocale
locale
formatCharacter _ 'H' = (FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String))
-> (FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String)
forall a b. (a -> b) -> a -> b
$ Bool
-> Int
-> Char
-> (TimeOfDay -> Int)
-> FormatOptions
-> TimeOfDay
-> String
forall i t.
ShowPadded i =>
Bool -> Int -> Char -> (t -> i) -> FormatOptions -> t -> String
formatNumber Bool
True 2 '0' TimeOfDay -> Int
todHour
formatCharacter _ 'I' = (FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String))
-> (FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String)
forall a b. (a -> b) -> a -> b
$ Bool
-> Int
-> Char
-> (TimeOfDay -> Int)
-> FormatOptions
-> TimeOfDay
-> String
forall i t.
ShowPadded i =>
Bool -> Int -> Char -> (t -> i) -> FormatOptions -> t -> String
formatNumber Bool
True 2 '0' TimeOfDay -> Int
tod12Hour
formatCharacter _ 'k' = (FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String))
-> (FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String)
forall a b. (a -> b) -> a -> b
$ Bool
-> Int
-> Char
-> (TimeOfDay -> Int)
-> FormatOptions
-> TimeOfDay
-> String
forall i t.
ShowPadded i =>
Bool -> Int -> Char -> (t -> i) -> FormatOptions -> t -> String
formatNumber Bool
True 2 ' ' TimeOfDay -> Int
todHour
formatCharacter _ 'l' = (FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String))
-> (FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String)
forall a b. (a -> b) -> a -> b
$ Bool
-> Int
-> Char
-> (TimeOfDay -> Int)
-> FormatOptions
-> TimeOfDay
-> String
forall i t.
ShowPadded i =>
Bool -> Int -> Char -> (t -> i) -> FormatOptions -> t -> String
formatNumber Bool
True 2 ' ' TimeOfDay -> Int
tod12Hour
formatCharacter _ 'M' = (FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String))
-> (FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String)
forall a b. (a -> b) -> a -> b
$ Bool
-> Int
-> Char
-> (TimeOfDay -> Int)
-> FormatOptions
-> TimeOfDay
-> String
forall i t.
ShowPadded i =>
Bool -> Int -> Char -> (t -> i) -> FormatOptions -> t -> String
formatNumber Bool
True 2 '0' TimeOfDay -> Int
todMin
formatCharacter _ 'S' = (FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String))
-> (FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String)
forall a b. (a -> b) -> a -> b
$ Bool
-> Int
-> Char
-> (TimeOfDay -> Int)
-> FormatOptions
-> TimeOfDay
-> String
forall i t.
ShowPadded i =>
Bool -> Int -> Char -> (t -> i) -> FormatOptions -> t -> String
formatNumber Bool
True 2 '0' ((TimeOfDay -> Int) -> FormatOptions -> TimeOfDay -> String)
-> (TimeOfDay -> Int) -> FormatOptions -> TimeOfDay -> String
forall a b. (a -> b) -> a -> b
$ (Pico -> Int
forall a b. (RealFrac a, Integral b) => a -> b
floor (Pico -> Int) -> (TimeOfDay -> Pico) -> TimeOfDay -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TimeOfDay -> Pico
todSec :: TimeOfDay -> Int)
formatCharacter _ 'q' = (FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String))
-> (FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String)
forall a b. (a -> b) -> a -> b
$ Bool
-> Bool
-> Int
-> Char
-> (TimeLocale -> PadOption -> TimeOfDay -> String)
-> FormatOptions
-> TimeOfDay
-> String
forall t.
Bool
-> Bool
-> Int
-> Char
-> (TimeLocale -> PadOption -> t -> String)
-> FormatOptions
-> t
-> String
formatGeneral Bool
True Bool
True 12 '0' ((TimeLocale -> PadOption -> TimeOfDay -> String)
-> FormatOptions -> TimeOfDay -> String)
-> (TimeLocale -> PadOption -> TimeOfDay -> String)
-> FormatOptions
-> TimeOfDay
-> String
forall a b. (a -> b) -> a -> b
$ \_ pado :: PadOption
pado -> PadOption -> Pico -> String
forall a. HasResolution a => PadOption -> Fixed a -> String
showPaddedFixedFraction PadOption
pado (Pico -> String) -> (TimeOfDay -> Pico) -> TimeOfDay -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TimeOfDay -> Pico
todSec
formatCharacter _ 'Q' = (FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String))
-> (FormatOptions -> TimeOfDay -> String)
-> Maybe (FormatOptions -> TimeOfDay -> String)
forall a b. (a -> b) -> a -> b
$ Bool
-> Bool
-> Int
-> Char
-> (TimeLocale -> PadOption -> TimeOfDay -> String)
-> FormatOptions
-> TimeOfDay
-> String
forall t.
Bool
-> Bool
-> Int
-> Char
-> (TimeLocale -> PadOption -> t -> String)
-> FormatOptions
-> t
-> String
formatGeneral Bool
True Bool
False 12 '0' ((TimeLocale -> PadOption -> TimeOfDay -> String)
-> FormatOptions -> TimeOfDay -> String)
-> (TimeLocale -> PadOption -> TimeOfDay -> String)
-> FormatOptions
-> TimeOfDay
-> String
forall a b. (a -> b) -> a -> b
$ \_ pado :: PadOption
pado -> String -> String
dotNonEmpty (String -> String) -> (TimeOfDay -> String) -> TimeOfDay -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PadOption -> Pico -> String
forall a. HasResolution a => PadOption -> Fixed a -> String
showPaddedFixedFraction PadOption
pado (Pico -> String) -> (TimeOfDay -> Pico) -> TimeOfDay -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TimeOfDay -> Pico
todSec where
dotNonEmpty :: String -> String
dotNonEmpty "" = ""
dotNonEmpty s :: String
s = '.'Char -> String -> String
forall a. a -> [a] -> [a]
:String
s
formatCharacter _ _ = Maybe (FormatOptions -> TimeOfDay -> String)
forall a. Maybe a
Nothing
instance FormatTime ZonedTime where
formatCharacter :: Bool -> Char -> Maybe (FormatOptions -> ZonedTime -> String)
formatCharacter _ 'c' = (FormatOptions -> ZonedTime -> String)
-> Maybe (FormatOptions -> ZonedTime -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> ZonedTime -> String)
-> Maybe (FormatOptions -> ZonedTime -> String))
-> (FormatOptions -> ZonedTime -> String)
-> Maybe (FormatOptions -> ZonedTime -> String)
forall a b. (a -> b) -> a -> b
$ (TimeLocale -> ZonedTime -> String)
-> FormatOptions -> ZonedTime -> String
forall t.
(TimeLocale -> t -> String) -> FormatOptions -> t -> String
formatString ((TimeLocale -> ZonedTime -> String)
-> FormatOptions -> ZonedTime -> String)
-> (TimeLocale -> ZonedTime -> String)
-> FormatOptions
-> ZonedTime
-> String
forall a b. (a -> b) -> a -> b
$ \locale :: TimeLocale
locale -> TimeLocale -> String -> ZonedTime -> String
forall t. FormatTime t => TimeLocale -> String -> t -> String
formatTime TimeLocale
locale (TimeLocale -> String
dateTimeFmt TimeLocale
locale)
formatCharacter _ 's' = (FormatOptions -> ZonedTime -> String)
-> Maybe (FormatOptions -> ZonedTime -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> ZonedTime -> String)
-> Maybe (FormatOptions -> ZonedTime -> String))
-> (FormatOptions -> ZonedTime -> String)
-> Maybe (FormatOptions -> ZonedTime -> String)
forall a b. (a -> b) -> a -> b
$ Bool
-> Int
-> Char
-> (ZonedTime -> Integer)
-> FormatOptions
-> ZonedTime
-> String
forall i t.
ShowPadded i =>
Bool -> Int -> Char -> (t -> i) -> FormatOptions -> t -> String
formatNumber Bool
True 1 '0' ((ZonedTime -> Integer) -> FormatOptions -> ZonedTime -> String)
-> (ZonedTime -> Integer) -> FormatOptions -> ZonedTime -> String
forall a b. (a -> b) -> a -> b
$ (POSIXTime -> Integer
forall a b. (RealFrac a, Integral b) => a -> b
floor (POSIXTime -> Integer)
-> (ZonedTime -> POSIXTime) -> ZonedTime -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UTCTime -> POSIXTime
utcTimeToPOSIXSeconds (UTCTime -> POSIXTime)
-> (ZonedTime -> UTCTime) -> ZonedTime -> POSIXTime
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ZonedTime -> UTCTime
zonedTimeToUTC :: ZonedTime -> Integer)
formatCharacter alt :: Bool
alt c :: Char
c = case Bool -> Char -> Maybe (FormatOptions -> LocalTime -> String)
forall t.
FormatTime t =>
Bool -> Char -> Maybe (FormatOptions -> t -> String)
formatCharacter Bool
alt Char
c of
Just f :: FormatOptions -> LocalTime -> String
f -> (FormatOptions -> ZonedTime -> String)
-> Maybe (FormatOptions -> ZonedTime -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> ZonedTime -> String)
-> Maybe (FormatOptions -> ZonedTime -> String))
-> (FormatOptions -> ZonedTime -> String)
-> Maybe (FormatOptions -> ZonedTime -> String)
forall a b. (a -> b) -> a -> b
$ \fo :: FormatOptions
fo dt :: ZonedTime
dt -> FormatOptions -> LocalTime -> String
f FormatOptions
fo (ZonedTime -> LocalTime
zonedTimeToLocalTime ZonedTime
dt)
Nothing -> case Bool -> Char -> Maybe (FormatOptions -> TimeZone -> String)
forall t.
FormatTime t =>
Bool -> Char -> Maybe (FormatOptions -> t -> String)
formatCharacter Bool
alt Char
c of
Just f :: FormatOptions -> TimeZone -> String
f -> (FormatOptions -> ZonedTime -> String)
-> Maybe (FormatOptions -> ZonedTime -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> ZonedTime -> String)
-> Maybe (FormatOptions -> ZonedTime -> String))
-> (FormatOptions -> ZonedTime -> String)
-> Maybe (FormatOptions -> ZonedTime -> String)
forall a b. (a -> b) -> a -> b
$ \fo :: FormatOptions
fo dt :: ZonedTime
dt -> FormatOptions -> TimeZone -> String
f FormatOptions
fo (ZonedTime -> TimeZone
zonedTimeZone ZonedTime
dt)
Nothing -> Maybe (FormatOptions -> ZonedTime -> String)
forall a. Maybe a
Nothing
instance FormatTime TimeZone where
formatCharacter :: Bool -> Char -> Maybe (FormatOptions -> TimeZone -> String)
formatCharacter False 'z' = (FormatOptions -> TimeZone -> String)
-> Maybe (FormatOptions -> TimeZone -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> TimeZone -> String)
-> Maybe (FormatOptions -> TimeZone -> String))
-> (FormatOptions -> TimeZone -> String)
-> Maybe (FormatOptions -> TimeZone -> String)
forall a b. (a -> b) -> a -> b
$ Bool
-> Bool
-> Int
-> Char
-> (TimeLocale -> PadOption -> TimeZone -> String)
-> FormatOptions
-> TimeZone
-> String
forall t.
Bool
-> Bool
-> Int
-> Char
-> (TimeLocale -> PadOption -> t -> String)
-> FormatOptions
-> t
-> String
formatGeneral Bool
False Bool
True 4 '0' ((TimeLocale -> PadOption -> TimeZone -> String)
-> FormatOptions -> TimeZone -> String)
-> (TimeLocale -> PadOption -> TimeZone -> String)
-> FormatOptions
-> TimeZone
-> String
forall a b. (a -> b) -> a -> b
$ \_ -> Bool -> PadOption -> TimeZone -> String
timeZoneOffsetString'' Bool
False
formatCharacter True 'z' = (FormatOptions -> TimeZone -> String)
-> Maybe (FormatOptions -> TimeZone -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> TimeZone -> String)
-> Maybe (FormatOptions -> TimeZone -> String))
-> (FormatOptions -> TimeZone -> String)
-> Maybe (FormatOptions -> TimeZone -> String)
forall a b. (a -> b) -> a -> b
$ Bool
-> Bool
-> Int
-> Char
-> (TimeLocale -> PadOption -> TimeZone -> String)
-> FormatOptions
-> TimeZone
-> String
forall t.
Bool
-> Bool
-> Int
-> Char
-> (TimeLocale -> PadOption -> t -> String)
-> FormatOptions
-> t
-> String
formatGeneral Bool
False Bool
True 5 '0' ((TimeLocale -> PadOption -> TimeZone -> String)
-> FormatOptions -> TimeZone -> String)
-> (TimeLocale -> PadOption -> TimeZone -> String)
-> FormatOptions
-> TimeZone
-> String
forall a b. (a -> b) -> a -> b
$ \_ -> Bool -> PadOption -> TimeZone -> String
timeZoneOffsetString'' Bool
True
formatCharacter alt :: Bool
alt 'Z' = (FormatOptions -> TimeZone -> String)
-> Maybe (FormatOptions -> TimeZone -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> TimeZone -> String)
-> Maybe (FormatOptions -> TimeZone -> String))
-> (FormatOptions -> TimeZone -> String)
-> Maybe (FormatOptions -> TimeZone -> String)
forall a b. (a -> b) -> a -> b
$ \fo :: FormatOptions
fo z :: TimeZone
z -> let
n :: String
n = TimeZone -> String
timeZoneName TimeZone
z
idef :: Int
idef = if Bool
alt then 5 else 4
in if String -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
n then Bool
-> Bool
-> Int
-> Char
-> (TimeLocale -> PadOption -> TimeZone -> String)
-> FormatOptions
-> TimeZone
-> String
forall t.
Bool
-> Bool
-> Int
-> Char
-> (TimeLocale -> PadOption -> t -> String)
-> FormatOptions
-> t
-> String
formatGeneral Bool
False Bool
True Int
idef '0' (\_ -> Bool -> PadOption -> TimeZone -> String
timeZoneOffsetString'' Bool
alt) FormatOptions
fo TimeZone
z else (TimeLocale -> TimeZone -> String)
-> FormatOptions -> TimeZone -> String
forall t.
(TimeLocale -> t -> String) -> FormatOptions -> t -> String
formatString (\_ -> TimeZone -> String
timeZoneName) FormatOptions
fo TimeZone
z
formatCharacter _ _ = Maybe (FormatOptions -> TimeZone -> String)
forall a. Maybe a
Nothing
instance FormatTime DayOfWeek where
formatCharacter :: Bool -> Char -> Maybe (FormatOptions -> DayOfWeek -> String)
formatCharacter _ 'u' = (FormatOptions -> DayOfWeek -> String)
-> Maybe (FormatOptions -> DayOfWeek -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> DayOfWeek -> String)
-> Maybe (FormatOptions -> DayOfWeek -> String))
-> (FormatOptions -> DayOfWeek -> String)
-> Maybe (FormatOptions -> DayOfWeek -> String)
forall a b. (a -> b) -> a -> b
$ Bool
-> Int
-> Char
-> (DayOfWeek -> Int)
-> FormatOptions
-> DayOfWeek
-> String
forall i t.
ShowPadded i =>
Bool -> Int -> Char -> (t -> i) -> FormatOptions -> t -> String
formatNumber Bool
True 1 '0' ((DayOfWeek -> Int) -> FormatOptions -> DayOfWeek -> String)
-> (DayOfWeek -> Int) -> FormatOptions -> DayOfWeek -> String
forall a b. (a -> b) -> a -> b
$ DayOfWeek -> Int
forall a. Enum a => a -> Int
fromEnum
formatCharacter _ 'w' = (FormatOptions -> DayOfWeek -> String)
-> Maybe (FormatOptions -> DayOfWeek -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> DayOfWeek -> String)
-> Maybe (FormatOptions -> DayOfWeek -> String))
-> (FormatOptions -> DayOfWeek -> String)
-> Maybe (FormatOptions -> DayOfWeek -> String)
forall a b. (a -> b) -> a -> b
$ Bool
-> Int
-> Char
-> (DayOfWeek -> Int)
-> FormatOptions
-> DayOfWeek
-> String
forall i t.
ShowPadded i =>
Bool -> Int -> Char -> (t -> i) -> FormatOptions -> t -> String
formatNumber Bool
True 1 '0' ((DayOfWeek -> Int) -> FormatOptions -> DayOfWeek -> String)
-> (DayOfWeek -> Int) -> FormatOptions -> DayOfWeek -> String
forall a b. (a -> b) -> a -> b
$ \wd :: DayOfWeek
wd -> (Int -> Int -> Int
forall a. Integral a => a -> a -> a
mod (DayOfWeek -> Int
forall a. Enum a => a -> Int
fromEnum DayOfWeek
wd) 7)
formatCharacter _ 'a' = (FormatOptions -> DayOfWeek -> String)
-> Maybe (FormatOptions -> DayOfWeek -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> DayOfWeek -> String)
-> Maybe (FormatOptions -> DayOfWeek -> String))
-> (FormatOptions -> DayOfWeek -> String)
-> Maybe (FormatOptions -> DayOfWeek -> String)
forall a b. (a -> b) -> a -> b
$ (TimeLocale -> DayOfWeek -> String)
-> FormatOptions -> DayOfWeek -> String
forall t.
(TimeLocale -> t -> String) -> FormatOptions -> t -> String
formatString ((TimeLocale -> DayOfWeek -> String)
-> FormatOptions -> DayOfWeek -> String)
-> (TimeLocale -> DayOfWeek -> String)
-> FormatOptions
-> DayOfWeek
-> String
forall a b. (a -> b) -> a -> b
$ \locale :: TimeLocale
locale wd :: DayOfWeek
wd -> (String, String) -> String
forall a b. (a, b) -> b
snd ((String, String) -> String) -> (String, String) -> String
forall a b. (a -> b) -> a -> b
$ (TimeLocale -> [(String, String)]
wDays TimeLocale
locale) [(String, String)] -> Int -> (String, String)
forall a. [a] -> Int -> a
!! (Int -> Int -> Int
forall a. Integral a => a -> a -> a
mod (DayOfWeek -> Int
forall a. Enum a => a -> Int
fromEnum DayOfWeek
wd) 7)
formatCharacter _ 'A' = (FormatOptions -> DayOfWeek -> String)
-> Maybe (FormatOptions -> DayOfWeek -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> DayOfWeek -> String)
-> Maybe (FormatOptions -> DayOfWeek -> String))
-> (FormatOptions -> DayOfWeek -> String)
-> Maybe (FormatOptions -> DayOfWeek -> String)
forall a b. (a -> b) -> a -> b
$ (TimeLocale -> DayOfWeek -> String)
-> FormatOptions -> DayOfWeek -> String
forall t.
(TimeLocale -> t -> String) -> FormatOptions -> t -> String
formatString ((TimeLocale -> DayOfWeek -> String)
-> FormatOptions -> DayOfWeek -> String)
-> (TimeLocale -> DayOfWeek -> String)
-> FormatOptions
-> DayOfWeek
-> String
forall a b. (a -> b) -> a -> b
$ \locale :: TimeLocale
locale wd :: DayOfWeek
wd -> (String, String) -> String
forall a b. (a, b) -> a
fst ((String, String) -> String) -> (String, String) -> String
forall a b. (a -> b) -> a -> b
$ (TimeLocale -> [(String, String)]
wDays TimeLocale
locale) [(String, String)] -> Int -> (String, String)
forall a. [a] -> Int -> a
!! (Int -> Int -> Int
forall a. Integral a => a -> a -> a
mod (DayOfWeek -> Int
forall a. Enum a => a -> Int
fromEnum DayOfWeek
wd) 7)
formatCharacter _ _ = Maybe (FormatOptions -> DayOfWeek -> String)
forall a. Maybe a
Nothing
instance FormatTime Day where
formatCharacter :: Bool -> Char -> Maybe (FormatOptions -> Day -> String)
formatCharacter _ 'D' = (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String))
-> (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a b. (a -> b) -> a -> b
$ (TimeLocale -> Day -> String) -> FormatOptions -> Day -> String
forall t.
(TimeLocale -> t -> String) -> FormatOptions -> t -> String
formatString ((TimeLocale -> Day -> String) -> FormatOptions -> Day -> String)
-> (TimeLocale -> Day -> String) -> FormatOptions -> Day -> String
forall a b. (a -> b) -> a -> b
$ \locale :: TimeLocale
locale -> TimeLocale -> String -> Day -> String
forall t. FormatTime t => TimeLocale -> String -> t -> String
formatTime TimeLocale
locale "%m/%d/%y"
formatCharacter _ 'F' = (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String))
-> (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a b. (a -> b) -> a -> b
$ (TimeLocale -> Day -> String) -> FormatOptions -> Day -> String
forall t.
(TimeLocale -> t -> String) -> FormatOptions -> t -> String
formatString ((TimeLocale -> Day -> String) -> FormatOptions -> Day -> String)
-> (TimeLocale -> Day -> String) -> FormatOptions -> Day -> String
forall a b. (a -> b) -> a -> b
$ \locale :: TimeLocale
locale -> TimeLocale -> String -> Day -> String
forall t. FormatTime t => TimeLocale -> String -> t -> String
formatTime TimeLocale
locale "%Y-%m-%d"
formatCharacter _ 'x' = (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String))
-> (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a b. (a -> b) -> a -> b
$ (TimeLocale -> Day -> String) -> FormatOptions -> Day -> String
forall t.
(TimeLocale -> t -> String) -> FormatOptions -> t -> String
formatString ((TimeLocale -> Day -> String) -> FormatOptions -> Day -> String)
-> (TimeLocale -> Day -> String) -> FormatOptions -> Day -> String
forall a b. (a -> b) -> a -> b
$ \locale :: TimeLocale
locale -> TimeLocale -> String -> Day -> String
forall t. FormatTime t => TimeLocale -> String -> t -> String
formatTime TimeLocale
locale (TimeLocale -> String
dateFmt TimeLocale
locale)
formatCharacter _ 'Y' = (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String))
-> (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a b. (a -> b) -> a -> b
$ Bool
-> Int
-> Char
-> (Day -> Integer)
-> FormatOptions
-> Day
-> String
forall i t.
ShowPadded i =>
Bool -> Int -> Char -> (t -> i) -> FormatOptions -> t -> String
formatNumber Bool
False 4 '0' ((Day -> Integer) -> FormatOptions -> Day -> String)
-> (Day -> Integer) -> FormatOptions -> Day -> String
forall a b. (a -> b) -> a -> b
$ (Integer, Int) -> Integer
forall a b. (a, b) -> a
fst ((Integer, Int) -> Integer)
-> (Day -> (Integer, Int)) -> Day -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Day -> (Integer, Int)
toOrdinalDate
formatCharacter _ 'y' = (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String))
-> (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a b. (a -> b) -> a -> b
$ Bool
-> Int
-> Char
-> (Day -> Integer)
-> FormatOptions
-> Day
-> String
forall i t.
ShowPadded i =>
Bool -> Int -> Char -> (t -> i) -> FormatOptions -> t -> String
formatNumber Bool
True 2 '0' ((Day -> Integer) -> FormatOptions -> Day -> String)
-> (Day -> Integer) -> FormatOptions -> Day -> String
forall a b. (a -> b) -> a -> b
$ Integer -> Integer
forall i. Integral i => i -> i
mod100 (Integer -> Integer) -> (Day -> Integer) -> Day -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Integer, Int) -> Integer
forall a b. (a, b) -> a
fst ((Integer, Int) -> Integer)
-> (Day -> (Integer, Int)) -> Day -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Day -> (Integer, Int)
toOrdinalDate
formatCharacter _ 'C' = (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String))
-> (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a b. (a -> b) -> a -> b
$ Bool
-> Int
-> Char
-> (Day -> Integer)
-> FormatOptions
-> Day
-> String
forall i t.
ShowPadded i =>
Bool -> Int -> Char -> (t -> i) -> FormatOptions -> t -> String
formatNumber Bool
False 2 '0' ((Day -> Integer) -> FormatOptions -> Day -> String)
-> (Day -> Integer) -> FormatOptions -> Day -> String
forall a b. (a -> b) -> a -> b
$ Integer -> Integer
forall i. Integral i => i -> i
div100 (Integer -> Integer) -> (Day -> Integer) -> Day -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Integer, Int) -> Integer
forall a b. (a, b) -> a
fst ((Integer, Int) -> Integer)
-> (Day -> (Integer, Int)) -> Day -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Day -> (Integer, Int)
toOrdinalDate
formatCharacter _ 'B' = (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String))
-> (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a b. (a -> b) -> a -> b
$ (TimeLocale -> Day -> String) -> FormatOptions -> Day -> String
forall t.
(TimeLocale -> t -> String) -> FormatOptions -> t -> String
formatString ((TimeLocale -> Day -> String) -> FormatOptions -> Day -> String)
-> (TimeLocale -> Day -> String) -> FormatOptions -> Day -> String
forall a b. (a -> b) -> a -> b
$ \locale :: TimeLocale
locale -> (String, String) -> String
forall a b. (a, b) -> a
fst ((String, String) -> String)
-> (Day -> (String, String)) -> Day -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (\(_,m :: Int
m,_) -> (TimeLocale -> [(String, String)]
months TimeLocale
locale) [(String, String)] -> Int -> (String, String)
forall a. [a] -> Int -> a
!! (Int
m Int -> Int -> Int
forall a. Num a => a -> a -> a
- 1)) ((Integer, Int, Int) -> (String, String))
-> (Day -> (Integer, Int, Int)) -> Day -> (String, String)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Day -> (Integer, Int, Int)
toGregorian
formatCharacter _ 'b' = (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String))
-> (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a b. (a -> b) -> a -> b
$ (TimeLocale -> Day -> String) -> FormatOptions -> Day -> String
forall t.
(TimeLocale -> t -> String) -> FormatOptions -> t -> String
formatString ((TimeLocale -> Day -> String) -> FormatOptions -> Day -> String)
-> (TimeLocale -> Day -> String) -> FormatOptions -> Day -> String
forall a b. (a -> b) -> a -> b
$ \locale :: TimeLocale
locale -> (String, String) -> String
forall a b. (a, b) -> b
snd ((String, String) -> String)
-> (Day -> (String, String)) -> Day -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (\(_,m :: Int
m,_) -> (TimeLocale -> [(String, String)]
months TimeLocale
locale) [(String, String)] -> Int -> (String, String)
forall a. [a] -> Int -> a
!! (Int
m Int -> Int -> Int
forall a. Num a => a -> a -> a
- 1)) ((Integer, Int, Int) -> (String, String))
-> (Day -> (Integer, Int, Int)) -> Day -> (String, String)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Day -> (Integer, Int, Int)
toGregorian
formatCharacter _ 'h' = (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String))
-> (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a b. (a -> b) -> a -> b
$ (TimeLocale -> Day -> String) -> FormatOptions -> Day -> String
forall t.
(TimeLocale -> t -> String) -> FormatOptions -> t -> String
formatString ((TimeLocale -> Day -> String) -> FormatOptions -> Day -> String)
-> (TimeLocale -> Day -> String) -> FormatOptions -> Day -> String
forall a b. (a -> b) -> a -> b
$ \locale :: TimeLocale
locale -> (String, String) -> String
forall a b. (a, b) -> b
snd ((String, String) -> String)
-> (Day -> (String, String)) -> Day -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (\(_,m :: Int
m,_) -> (TimeLocale -> [(String, String)]
months TimeLocale
locale) [(String, String)] -> Int -> (String, String)
forall a. [a] -> Int -> a
!! (Int
m Int -> Int -> Int
forall a. Num a => a -> a -> a
- 1)) ((Integer, Int, Int) -> (String, String))
-> (Day -> (Integer, Int, Int)) -> Day -> (String, String)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Day -> (Integer, Int, Int)
toGregorian
formatCharacter _ 'm' = (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String))
-> (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a b. (a -> b) -> a -> b
$ Bool
-> Int -> Char -> (Day -> Int) -> FormatOptions -> Day -> String
forall i t.
ShowPadded i =>
Bool -> Int -> Char -> (t -> i) -> FormatOptions -> t -> String
formatNumber Bool
True 2 '0' ((Day -> Int) -> FormatOptions -> Day -> String)
-> (Day -> Int) -> FormatOptions -> Day -> String
forall a b. (a -> b) -> a -> b
$ (\(_,m :: Int
m,_) -> Int
m) ((Integer, Int, Int) -> Int)
-> (Day -> (Integer, Int, Int)) -> Day -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Day -> (Integer, Int, Int)
toGregorian
formatCharacter _ 'd' = (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String))
-> (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a b. (a -> b) -> a -> b
$ Bool
-> Int -> Char -> (Day -> Int) -> FormatOptions -> Day -> String
forall i t.
ShowPadded i =>
Bool -> Int -> Char -> (t -> i) -> FormatOptions -> t -> String
formatNumber Bool
True 2 '0' ((Day -> Int) -> FormatOptions -> Day -> String)
-> (Day -> Int) -> FormatOptions -> Day -> String
forall a b. (a -> b) -> a -> b
$ (\(_,_,d :: Int
d) -> Int
d) ((Integer, Int, Int) -> Int)
-> (Day -> (Integer, Int, Int)) -> Day -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Day -> (Integer, Int, Int)
toGregorian
formatCharacter _ 'e' = (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String))
-> (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a b. (a -> b) -> a -> b
$ Bool
-> Int -> Char -> (Day -> Int) -> FormatOptions -> Day -> String
forall i t.
ShowPadded i =>
Bool -> Int -> Char -> (t -> i) -> FormatOptions -> t -> String
formatNumber Bool
True 2 ' ' ((Day -> Int) -> FormatOptions -> Day -> String)
-> (Day -> Int) -> FormatOptions -> Day -> String
forall a b. (a -> b) -> a -> b
$ (\(_,_,d :: Int
d) -> Int
d) ((Integer, Int, Int) -> Int)
-> (Day -> (Integer, Int, Int)) -> Day -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Day -> (Integer, Int, Int)
toGregorian
formatCharacter _ 'j' = (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String))
-> (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a b. (a -> b) -> a -> b
$ Bool
-> Int -> Char -> (Day -> Int) -> FormatOptions -> Day -> String
forall i t.
ShowPadded i =>
Bool -> Int -> Char -> (t -> i) -> FormatOptions -> t -> String
formatNumber Bool
True 3 '0' ((Day -> Int) -> FormatOptions -> Day -> String)
-> (Day -> Int) -> FormatOptions -> Day -> String
forall a b. (a -> b) -> a -> b
$ (Integer, Int) -> Int
forall a b. (a, b) -> b
snd ((Integer, Int) -> Int) -> (Day -> (Integer, Int)) -> Day -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Day -> (Integer, Int)
toOrdinalDate
formatCharacter _ 'G' = (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String))
-> (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a b. (a -> b) -> a -> b
$ Bool
-> Int
-> Char
-> (Day -> Integer)
-> FormatOptions
-> Day
-> String
forall i t.
ShowPadded i =>
Bool -> Int -> Char -> (t -> i) -> FormatOptions -> t -> String
formatNumber Bool
False 4 '0' ((Day -> Integer) -> FormatOptions -> Day -> String)
-> (Day -> Integer) -> FormatOptions -> Day -> String
forall a b. (a -> b) -> a -> b
$ (\(y :: Integer
y,_,_) -> Integer
y) ((Integer, Int, Int) -> Integer)
-> (Day -> (Integer, Int, Int)) -> Day -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Day -> (Integer, Int, Int)
toWeekDate
formatCharacter _ 'g' = (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String))
-> (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a b. (a -> b) -> a -> b
$ Bool
-> Int
-> Char
-> (Day -> Integer)
-> FormatOptions
-> Day
-> String
forall i t.
ShowPadded i =>
Bool -> Int -> Char -> (t -> i) -> FormatOptions -> t -> String
formatNumber Bool
True 2 '0' ((Day -> Integer) -> FormatOptions -> Day -> String)
-> (Day -> Integer) -> FormatOptions -> Day -> String
forall a b. (a -> b) -> a -> b
$ Integer -> Integer
forall i. Integral i => i -> i
mod100 (Integer -> Integer) -> (Day -> Integer) -> Day -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (\(y :: Integer
y,_,_) -> Integer
y) ((Integer, Int, Int) -> Integer)
-> (Day -> (Integer, Int, Int)) -> Day -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Day -> (Integer, Int, Int)
toWeekDate
formatCharacter _ 'f' = (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String))
-> (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a b. (a -> b) -> a -> b
$ Bool
-> Int
-> Char
-> (Day -> Integer)
-> FormatOptions
-> Day
-> String
forall i t.
ShowPadded i =>
Bool -> Int -> Char -> (t -> i) -> FormatOptions -> t -> String
formatNumber Bool
False 2 '0' ((Day -> Integer) -> FormatOptions -> Day -> String)
-> (Day -> Integer) -> FormatOptions -> Day -> String
forall a b. (a -> b) -> a -> b
$ Integer -> Integer
forall i. Integral i => i -> i
div100 (Integer -> Integer) -> (Day -> Integer) -> Day -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (\(y :: Integer
y,_,_) -> Integer
y) ((Integer, Int, Int) -> Integer)
-> (Day -> (Integer, Int, Int)) -> Day -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Day -> (Integer, Int, Int)
toWeekDate
formatCharacter _ 'V' = (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String))
-> (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a b. (a -> b) -> a -> b
$ Bool
-> Int -> Char -> (Day -> Int) -> FormatOptions -> Day -> String
forall i t.
ShowPadded i =>
Bool -> Int -> Char -> (t -> i) -> FormatOptions -> t -> String
formatNumber Bool
True 2 '0' ((Day -> Int) -> FormatOptions -> Day -> String)
-> (Day -> Int) -> FormatOptions -> Day -> String
forall a b. (a -> b) -> a -> b
$ (\(_,w :: Int
w,_) -> Int
w) ((Integer, Int, Int) -> Int)
-> (Day -> (Integer, Int, Int)) -> Day -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Day -> (Integer, Int, Int)
toWeekDate
formatCharacter _ 'u' = (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String))
-> (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a b. (a -> b) -> a -> b
$ Bool
-> Int -> Char -> (Day -> Int) -> FormatOptions -> Day -> String
forall i t.
ShowPadded i =>
Bool -> Int -> Char -> (t -> i) -> FormatOptions -> t -> String
formatNumber Bool
True 1 '0' ((Day -> Int) -> FormatOptions -> Day -> String)
-> (Day -> Int) -> FormatOptions -> Day -> String
forall a b. (a -> b) -> a -> b
$ (\(_,_,d :: Int
d) -> Int
d) ((Integer, Int, Int) -> Int)
-> (Day -> (Integer, Int, Int)) -> Day -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Day -> (Integer, Int, Int)
toWeekDate
formatCharacter _ 'a' = (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String))
-> (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a b. (a -> b) -> a -> b
$ (TimeLocale -> Day -> String) -> FormatOptions -> Day -> String
forall t.
(TimeLocale -> t -> String) -> FormatOptions -> t -> String
formatString ((TimeLocale -> Day -> String) -> FormatOptions -> Day -> String)
-> (TimeLocale -> Day -> String) -> FormatOptions -> Day -> String
forall a b. (a -> b) -> a -> b
$ \locale :: TimeLocale
locale -> (String, String) -> String
forall a b. (a, b) -> b
snd ((String, String) -> String)
-> (Day -> (String, String)) -> Day -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((TimeLocale -> [(String, String)]
wDays TimeLocale
locale) [(String, String)] -> Int -> (String, String)
forall a. [a] -> Int -> a
!!) (Int -> (String, String))
-> (Day -> Int) -> Day -> (String, String)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int) -> Int
forall a b. (a, b) -> b
snd ((Int, Int) -> Int) -> (Day -> (Int, Int)) -> Day -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Day -> (Int, Int)
sundayStartWeek
formatCharacter _ 'A' = (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String))
-> (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a b. (a -> b) -> a -> b
$ (TimeLocale -> Day -> String) -> FormatOptions -> Day -> String
forall t.
(TimeLocale -> t -> String) -> FormatOptions -> t -> String
formatString ((TimeLocale -> Day -> String) -> FormatOptions -> Day -> String)
-> (TimeLocale -> Day -> String) -> FormatOptions -> Day -> String
forall a b. (a -> b) -> a -> b
$ \locale :: TimeLocale
locale -> (String, String) -> String
forall a b. (a, b) -> a
fst ((String, String) -> String)
-> (Day -> (String, String)) -> Day -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((TimeLocale -> [(String, String)]
wDays TimeLocale
locale) [(String, String)] -> Int -> (String, String)
forall a. [a] -> Int -> a
!!) (Int -> (String, String))
-> (Day -> Int) -> Day -> (String, String)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int) -> Int
forall a b. (a, b) -> b
snd ((Int, Int) -> Int) -> (Day -> (Int, Int)) -> Day -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Day -> (Int, Int)
sundayStartWeek
formatCharacter _ 'U' = (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String))
-> (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a b. (a -> b) -> a -> b
$ Bool
-> Int -> Char -> (Day -> Int) -> FormatOptions -> Day -> String
forall i t.
ShowPadded i =>
Bool -> Int -> Char -> (t -> i) -> FormatOptions -> t -> String
formatNumber Bool
True 2 '0' ((Day -> Int) -> FormatOptions -> Day -> String)
-> (Day -> Int) -> FormatOptions -> Day -> String
forall a b. (a -> b) -> a -> b
$ (Int, Int) -> Int
forall a b. (a, b) -> a
fst ((Int, Int) -> Int) -> (Day -> (Int, Int)) -> Day -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Day -> (Int, Int)
sundayStartWeek
formatCharacter _ 'w' = (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String))
-> (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a b. (a -> b) -> a -> b
$ Bool
-> Int -> Char -> (Day -> Int) -> FormatOptions -> Day -> String
forall i t.
ShowPadded i =>
Bool -> Int -> Char -> (t -> i) -> FormatOptions -> t -> String
formatNumber Bool
True 1 '0' ((Day -> Int) -> FormatOptions -> Day -> String)
-> (Day -> Int) -> FormatOptions -> Day -> String
forall a b. (a -> b) -> a -> b
$ (Int, Int) -> Int
forall a b. (a, b) -> b
snd ((Int, Int) -> Int) -> (Day -> (Int, Int)) -> Day -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Day -> (Int, Int)
sundayStartWeek
formatCharacter _ 'W' = (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String))
-> (FormatOptions -> Day -> String)
-> Maybe (FormatOptions -> Day -> String)
forall a b. (a -> b) -> a -> b
$ Bool
-> Int -> Char -> (Day -> Int) -> FormatOptions -> Day -> String
forall i t.
ShowPadded i =>
Bool -> Int -> Char -> (t -> i) -> FormatOptions -> t -> String
formatNumber Bool
True 2 '0' ((Day -> Int) -> FormatOptions -> Day -> String)
-> (Day -> Int) -> FormatOptions -> Day -> String
forall a b. (a -> b) -> a -> b
$ (Int, Int) -> Int
forall a b. (a, b) -> a
fst ((Int, Int) -> Int) -> (Day -> (Int, Int)) -> Day -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Day -> (Int, Int)
mondayStartWeek
formatCharacter _ _ = Maybe (FormatOptions -> Day -> String)
forall a. Maybe a
Nothing
instance FormatTime UTCTime where
formatCharacter :: Bool -> Char -> Maybe (FormatOptions -> UTCTime -> String)
formatCharacter alt :: Bool
alt c :: Char
c = ((FormatOptions -> ZonedTime -> String)
-> FormatOptions -> UTCTime -> String)
-> Maybe (FormatOptions -> ZonedTime -> String)
-> Maybe (FormatOptions -> UTCTime -> String)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\f :: FormatOptions -> ZonedTime -> String
f fo :: FormatOptions
fo t :: UTCTime
t -> FormatOptions -> ZonedTime -> String
f FormatOptions
fo (TimeZone -> UTCTime -> ZonedTime
utcToZonedTime TimeZone
utc UTCTime
t)) (Bool -> Char -> Maybe (FormatOptions -> ZonedTime -> String)
forall t.
FormatTime t =>
Bool -> Char -> Maybe (FormatOptions -> t -> String)
formatCharacter Bool
alt Char
c)
instance FormatTime UniversalTime where
formatCharacter :: Bool -> Char -> Maybe (FormatOptions -> UniversalTime -> String)
formatCharacter alt :: Bool
alt c :: Char
c = ((FormatOptions -> LocalTime -> String)
-> FormatOptions -> UniversalTime -> String)
-> Maybe (FormatOptions -> LocalTime -> String)
-> Maybe (FormatOptions -> UniversalTime -> String)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\f :: FormatOptions -> LocalTime -> String
f fo :: FormatOptions
fo t :: UniversalTime
t -> FormatOptions -> LocalTime -> String
f FormatOptions
fo (Rational -> UniversalTime -> LocalTime
ut1ToLocalTime 0 UniversalTime
t)) (Bool -> Char -> Maybe (FormatOptions -> LocalTime -> String)
forall t.
FormatTime t =>
Bool -> Char -> Maybe (FormatOptions -> t -> String)
formatCharacter Bool
alt Char
c)
instance FormatTime NominalDiffTime where
formatCharacter :: Bool -> Char -> Maybe (FormatOptions -> POSIXTime -> String)
formatCharacter _ 'w' = (FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String))
-> (FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String)
forall a b. (a -> b) -> a -> b
$ Int
-> (POSIXTime -> Integer) -> FormatOptions -> POSIXTime -> String
forall t. Int -> (t -> Integer) -> FormatOptions -> t -> String
formatNumberStd 1 ((POSIXTime -> Integer) -> FormatOptions -> POSIXTime -> String)
-> (POSIXTime -> Integer) -> FormatOptions -> POSIXTime -> String
forall a b. (a -> b) -> a -> b
$ POSIXTime -> POSIXTime -> Integer
forall a b. (Real a, Integral b) => a -> a -> b
quotBy (POSIXTime -> POSIXTime -> Integer)
-> POSIXTime -> POSIXTime -> Integer
forall a b. (a -> b) -> a -> b
$ 7 POSIXTime -> POSIXTime -> POSIXTime
forall a. Num a => a -> a -> a
* 86400
formatCharacter _ 'd' = (FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String))
-> (FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String)
forall a b. (a -> b) -> a -> b
$ Int
-> (POSIXTime -> Integer) -> FormatOptions -> POSIXTime -> String
forall t. Int -> (t -> Integer) -> FormatOptions -> t -> String
formatNumberStd 1 ((POSIXTime -> Integer) -> FormatOptions -> POSIXTime -> String)
-> (POSIXTime -> Integer) -> FormatOptions -> POSIXTime -> String
forall a b. (a -> b) -> a -> b
$ POSIXTime -> POSIXTime -> Integer
forall a b. (Real a, Integral b) => a -> a -> b
quotBy 86400
formatCharacter _ 'D' = (FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String))
-> (FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String)
forall a b. (a -> b) -> a -> b
$ Int
-> (POSIXTime -> Integer) -> FormatOptions -> POSIXTime -> String
forall t. Int -> (t -> Integer) -> FormatOptions -> t -> String
formatNumberStd 1 ((POSIXTime -> Integer) -> FormatOptions -> POSIXTime -> String)
-> (POSIXTime -> Integer) -> FormatOptions -> POSIXTime -> String
forall a b. (a -> b) -> a -> b
$ Integer -> Integer -> Integer
forall a. Real a => a -> a -> a
remBy 7 (Integer -> Integer)
-> (POSIXTime -> Integer) -> POSIXTime -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. POSIXTime -> POSIXTime -> Integer
forall a b. (Real a, Integral b) => a -> a -> b
quotBy 86400
formatCharacter _ 'h' = (FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String))
-> (FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String)
forall a b. (a -> b) -> a -> b
$ Int
-> (POSIXTime -> Integer) -> FormatOptions -> POSIXTime -> String
forall t. Int -> (t -> Integer) -> FormatOptions -> t -> String
formatNumberStd 1 ((POSIXTime -> Integer) -> FormatOptions -> POSIXTime -> String)
-> (POSIXTime -> Integer) -> FormatOptions -> POSIXTime -> String
forall a b. (a -> b) -> a -> b
$ POSIXTime -> POSIXTime -> Integer
forall a b. (Real a, Integral b) => a -> a -> b
quotBy 3600
formatCharacter _ 'H' = (FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String))
-> (FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String)
forall a b. (a -> b) -> a -> b
$ Int
-> (POSIXTime -> Integer) -> FormatOptions -> POSIXTime -> String
forall t. Int -> (t -> Integer) -> FormatOptions -> t -> String
formatNumberStd 2 ((POSIXTime -> Integer) -> FormatOptions -> POSIXTime -> String)
-> (POSIXTime -> Integer) -> FormatOptions -> POSIXTime -> String
forall a b. (a -> b) -> a -> b
$ Integer -> Integer -> Integer
forall a. Real a => a -> a -> a
remBy 24 (Integer -> Integer)
-> (POSIXTime -> Integer) -> POSIXTime -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. POSIXTime -> POSIXTime -> Integer
forall a b. (Real a, Integral b) => a -> a -> b
quotBy 3600
formatCharacter _ 'm' = (FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String))
-> (FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String)
forall a b. (a -> b) -> a -> b
$ Int
-> (POSIXTime -> Integer) -> FormatOptions -> POSIXTime -> String
forall t. Int -> (t -> Integer) -> FormatOptions -> t -> String
formatNumberStd 1 ((POSIXTime -> Integer) -> FormatOptions -> POSIXTime -> String)
-> (POSIXTime -> Integer) -> FormatOptions -> POSIXTime -> String
forall a b. (a -> b) -> a -> b
$ POSIXTime -> POSIXTime -> Integer
forall a b. (Real a, Integral b) => a -> a -> b
quotBy 60
formatCharacter _ 'M' = (FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String))
-> (FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String)
forall a b. (a -> b) -> a -> b
$ Int
-> (POSIXTime -> Integer) -> FormatOptions -> POSIXTime -> String
forall t. Int -> (t -> Integer) -> FormatOptions -> t -> String
formatNumberStd 2 ((POSIXTime -> Integer) -> FormatOptions -> POSIXTime -> String)
-> (POSIXTime -> Integer) -> FormatOptions -> POSIXTime -> String
forall a b. (a -> b) -> a -> b
$ Integer -> Integer -> Integer
forall a. Real a => a -> a -> a
remBy 60 (Integer -> Integer)
-> (POSIXTime -> Integer) -> POSIXTime -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. POSIXTime -> POSIXTime -> Integer
forall a b. (Real a, Integral b) => a -> a -> b
quotBy 60
formatCharacter False 's' = (FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String))
-> (FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String)
forall a b. (a -> b) -> a -> b
$ Int
-> (POSIXTime -> Integer) -> FormatOptions -> POSIXTime -> String
forall t. Int -> (t -> Integer) -> FormatOptions -> t -> String
formatNumberStd 1 ((POSIXTime -> Integer) -> FormatOptions -> POSIXTime -> String)
-> (POSIXTime -> Integer) -> FormatOptions -> POSIXTime -> String
forall a b. (a -> b) -> a -> b
$ POSIXTime -> POSIXTime -> Integer
forall a b. (Real a, Integral b) => a -> a -> b
quotBy 1
formatCharacter True 's' = (FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String))
-> (FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String)
forall a b. (a -> b) -> a -> b
$ Bool
-> Bool
-> Int
-> Char
-> (TimeLocale -> PadOption -> POSIXTime -> String)
-> FormatOptions
-> POSIXTime
-> String
forall t.
Bool
-> Bool
-> Int
-> Char
-> (TimeLocale -> PadOption -> t -> String)
-> FormatOptions
-> t
-> String
formatGeneral Bool
False Bool
False 12 '0' ((TimeLocale -> PadOption -> POSIXTime -> String)
-> FormatOptions -> POSIXTime -> String)
-> (TimeLocale -> PadOption -> POSIXTime -> String)
-> FormatOptions
-> POSIXTime
-> String
forall a b. (a -> b) -> a -> b
$ \_ padf :: PadOption
padf t :: POSIXTime
t -> PadOption -> PadOption -> Pico -> String
forall a.
HasResolution a =>
PadOption -> PadOption -> Fixed a -> String
showPaddedFixed PadOption
NoPad PadOption
padf (POSIXTime -> Pico
forall a b. (Real a, Fractional b) => a -> b
realToFrac POSIXTime
t :: Pico)
formatCharacter False 'S' = (FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String))
-> (FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String)
forall a b. (a -> b) -> a -> b
$ Int
-> (POSIXTime -> Integer) -> FormatOptions -> POSIXTime -> String
forall t. Int -> (t -> Integer) -> FormatOptions -> t -> String
formatNumberStd 2 ((POSIXTime -> Integer) -> FormatOptions -> POSIXTime -> String)
-> (POSIXTime -> Integer) -> FormatOptions -> POSIXTime -> String
forall a b. (a -> b) -> a -> b
$ Integer -> Integer -> Integer
forall a. Real a => a -> a -> a
remBy 60 (Integer -> Integer)
-> (POSIXTime -> Integer) -> POSIXTime -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. POSIXTime -> POSIXTime -> Integer
forall a b. (Real a, Integral b) => a -> a -> b
quotBy 1
formatCharacter True 'S' = (FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String))
-> (FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String)
forall a b. (a -> b) -> a -> b
$ Bool
-> Bool
-> Int
-> Char
-> (TimeLocale -> PadOption -> POSIXTime -> String)
-> FormatOptions
-> POSIXTime
-> String
forall t.
Bool
-> Bool
-> Int
-> Char
-> (TimeLocale -> PadOption -> t -> String)
-> FormatOptions
-> t
-> String
formatGeneral Bool
False Bool
False 12 '0' ((TimeLocale -> PadOption -> POSIXTime -> String)
-> FormatOptions -> POSIXTime -> String)
-> (TimeLocale -> PadOption -> POSIXTime -> String)
-> FormatOptions
-> POSIXTime
-> String
forall a b. (a -> b) -> a -> b
$ \_ padf :: PadOption
padf t :: POSIXTime
t -> let
padn :: PadOption
padn = case PadOption
padf of
NoPad -> PadOption
NoPad
Pad _ c :: Char
c -> Int -> Char -> PadOption
Pad 2 Char
c
in PadOption -> PadOption -> Pico -> String
forall a.
HasResolution a =>
PadOption -> PadOption -> Fixed a -> String
showPaddedFixed PadOption
padn PadOption
padf (POSIXTime -> Pico
forall a b. (Real a, Fractional b) => a -> b
realToFrac (POSIXTime -> Pico) -> POSIXTime -> Pico
forall a b. (a -> b) -> a -> b
$ POSIXTime -> POSIXTime -> POSIXTime
forall a. Real a => a -> a -> a
remBy 60 POSIXTime
t :: Pico)
formatCharacter _ _ = Maybe (FormatOptions -> POSIXTime -> String)
forall a. Maybe a
Nothing
instance FormatTime DiffTime where
formatCharacter :: Bool -> Char -> Maybe (FormatOptions -> DiffTime -> String)
formatCharacter _ 'w' = (FormatOptions -> DiffTime -> String)
-> Maybe (FormatOptions -> DiffTime -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> DiffTime -> String)
-> Maybe (FormatOptions -> DiffTime -> String))
-> (FormatOptions -> DiffTime -> String)
-> Maybe (FormatOptions -> DiffTime -> String)
forall a b. (a -> b) -> a -> b
$ Int -> (DiffTime -> Integer) -> FormatOptions -> DiffTime -> String
forall t. Int -> (t -> Integer) -> FormatOptions -> t -> String
formatNumberStd 1 ((DiffTime -> Integer) -> FormatOptions -> DiffTime -> String)
-> (DiffTime -> Integer) -> FormatOptions -> DiffTime -> String
forall a b. (a -> b) -> a -> b
$ DiffTime -> DiffTime -> Integer
forall a b. (Real a, Integral b) => a -> a -> b
quotBy (DiffTime -> DiffTime -> Integer)
-> DiffTime -> DiffTime -> Integer
forall a b. (a -> b) -> a -> b
$ 7 DiffTime -> DiffTime -> DiffTime
forall a. Num a => a -> a -> a
* 86400
formatCharacter _ 'd' = (FormatOptions -> DiffTime -> String)
-> Maybe (FormatOptions -> DiffTime -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> DiffTime -> String)
-> Maybe (FormatOptions -> DiffTime -> String))
-> (FormatOptions -> DiffTime -> String)
-> Maybe (FormatOptions -> DiffTime -> String)
forall a b. (a -> b) -> a -> b
$ Int -> (DiffTime -> Integer) -> FormatOptions -> DiffTime -> String
forall t. Int -> (t -> Integer) -> FormatOptions -> t -> String
formatNumberStd 1 ((DiffTime -> Integer) -> FormatOptions -> DiffTime -> String)
-> (DiffTime -> Integer) -> FormatOptions -> DiffTime -> String
forall a b. (a -> b) -> a -> b
$ DiffTime -> DiffTime -> Integer
forall a b. (Real a, Integral b) => a -> a -> b
quotBy 86400
formatCharacter _ 'D' = (FormatOptions -> DiffTime -> String)
-> Maybe (FormatOptions -> DiffTime -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> DiffTime -> String)
-> Maybe (FormatOptions -> DiffTime -> String))
-> (FormatOptions -> DiffTime -> String)
-> Maybe (FormatOptions -> DiffTime -> String)
forall a b. (a -> b) -> a -> b
$ Int -> (DiffTime -> Integer) -> FormatOptions -> DiffTime -> String
forall t. Int -> (t -> Integer) -> FormatOptions -> t -> String
formatNumberStd 1 ((DiffTime -> Integer) -> FormatOptions -> DiffTime -> String)
-> (DiffTime -> Integer) -> FormatOptions -> DiffTime -> String
forall a b. (a -> b) -> a -> b
$ Integer -> Integer -> Integer
forall a. Real a => a -> a -> a
remBy 7 (Integer -> Integer)
-> (DiffTime -> Integer) -> DiffTime -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DiffTime -> DiffTime -> Integer
forall a b. (Real a, Integral b) => a -> a -> b
quotBy 86400
formatCharacter _ 'h' = (FormatOptions -> DiffTime -> String)
-> Maybe (FormatOptions -> DiffTime -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> DiffTime -> String)
-> Maybe (FormatOptions -> DiffTime -> String))
-> (FormatOptions -> DiffTime -> String)
-> Maybe (FormatOptions -> DiffTime -> String)
forall a b. (a -> b) -> a -> b
$ Int -> (DiffTime -> Integer) -> FormatOptions -> DiffTime -> String
forall t. Int -> (t -> Integer) -> FormatOptions -> t -> String
formatNumberStd 1 ((DiffTime -> Integer) -> FormatOptions -> DiffTime -> String)
-> (DiffTime -> Integer) -> FormatOptions -> DiffTime -> String
forall a b. (a -> b) -> a -> b
$ DiffTime -> DiffTime -> Integer
forall a b. (Real a, Integral b) => a -> a -> b
quotBy 3600
formatCharacter _ 'H' = (FormatOptions -> DiffTime -> String)
-> Maybe (FormatOptions -> DiffTime -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> DiffTime -> String)
-> Maybe (FormatOptions -> DiffTime -> String))
-> (FormatOptions -> DiffTime -> String)
-> Maybe (FormatOptions -> DiffTime -> String)
forall a b. (a -> b) -> a -> b
$ Int -> (DiffTime -> Integer) -> FormatOptions -> DiffTime -> String
forall t. Int -> (t -> Integer) -> FormatOptions -> t -> String
formatNumberStd 2 ((DiffTime -> Integer) -> FormatOptions -> DiffTime -> String)
-> (DiffTime -> Integer) -> FormatOptions -> DiffTime -> String
forall a b. (a -> b) -> a -> b
$ Integer -> Integer -> Integer
forall a. Real a => a -> a -> a
remBy 24 (Integer -> Integer)
-> (DiffTime -> Integer) -> DiffTime -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DiffTime -> DiffTime -> Integer
forall a b. (Real a, Integral b) => a -> a -> b
quotBy 3600
formatCharacter _ 'm' = (FormatOptions -> DiffTime -> String)
-> Maybe (FormatOptions -> DiffTime -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> DiffTime -> String)
-> Maybe (FormatOptions -> DiffTime -> String))
-> (FormatOptions -> DiffTime -> String)
-> Maybe (FormatOptions -> DiffTime -> String)
forall a b. (a -> b) -> a -> b
$ Int -> (DiffTime -> Integer) -> FormatOptions -> DiffTime -> String
forall t. Int -> (t -> Integer) -> FormatOptions -> t -> String
formatNumberStd 1 ((DiffTime -> Integer) -> FormatOptions -> DiffTime -> String)
-> (DiffTime -> Integer) -> FormatOptions -> DiffTime -> String
forall a b. (a -> b) -> a -> b
$ DiffTime -> DiffTime -> Integer
forall a b. (Real a, Integral b) => a -> a -> b
quotBy 60
formatCharacter _ 'M' = (FormatOptions -> DiffTime -> String)
-> Maybe (FormatOptions -> DiffTime -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> DiffTime -> String)
-> Maybe (FormatOptions -> DiffTime -> String))
-> (FormatOptions -> DiffTime -> String)
-> Maybe (FormatOptions -> DiffTime -> String)
forall a b. (a -> b) -> a -> b
$ Int -> (DiffTime -> Integer) -> FormatOptions -> DiffTime -> String
forall t. Int -> (t -> Integer) -> FormatOptions -> t -> String
formatNumberStd 2 ((DiffTime -> Integer) -> FormatOptions -> DiffTime -> String)
-> (DiffTime -> Integer) -> FormatOptions -> DiffTime -> String
forall a b. (a -> b) -> a -> b
$ Integer -> Integer -> Integer
forall a. Real a => a -> a -> a
remBy 60 (Integer -> Integer)
-> (DiffTime -> Integer) -> DiffTime -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DiffTime -> DiffTime -> Integer
forall a b. (Real a, Integral b) => a -> a -> b
quotBy 60
formatCharacter False 's' = (FormatOptions -> DiffTime -> String)
-> Maybe (FormatOptions -> DiffTime -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> DiffTime -> String)
-> Maybe (FormatOptions -> DiffTime -> String))
-> (FormatOptions -> DiffTime -> String)
-> Maybe (FormatOptions -> DiffTime -> String)
forall a b. (a -> b) -> a -> b
$ Int -> (DiffTime -> Integer) -> FormatOptions -> DiffTime -> String
forall t. Int -> (t -> Integer) -> FormatOptions -> t -> String
formatNumberStd 1 ((DiffTime -> Integer) -> FormatOptions -> DiffTime -> String)
-> (DiffTime -> Integer) -> FormatOptions -> DiffTime -> String
forall a b. (a -> b) -> a -> b
$ DiffTime -> DiffTime -> Integer
forall a b. (Real a, Integral b) => a -> a -> b
quotBy 1
formatCharacter True 's' = (FormatOptions -> DiffTime -> String)
-> Maybe (FormatOptions -> DiffTime -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> DiffTime -> String)
-> Maybe (FormatOptions -> DiffTime -> String))
-> (FormatOptions -> DiffTime -> String)
-> Maybe (FormatOptions -> DiffTime -> String)
forall a b. (a -> b) -> a -> b
$ Bool
-> Bool
-> Int
-> Char
-> (TimeLocale -> PadOption -> DiffTime -> String)
-> FormatOptions
-> DiffTime
-> String
forall t.
Bool
-> Bool
-> Int
-> Char
-> (TimeLocale -> PadOption -> t -> String)
-> FormatOptions
-> t
-> String
formatGeneral Bool
False Bool
False 12 '0' ((TimeLocale -> PadOption -> DiffTime -> String)
-> FormatOptions -> DiffTime -> String)
-> (TimeLocale -> PadOption -> DiffTime -> String)
-> FormatOptions
-> DiffTime
-> String
forall a b. (a -> b) -> a -> b
$ \_ padf :: PadOption
padf t :: DiffTime
t -> PadOption -> PadOption -> Pico -> String
forall a.
HasResolution a =>
PadOption -> PadOption -> Fixed a -> String
showPaddedFixed PadOption
NoPad PadOption
padf (DiffTime -> Pico
forall a b. (Real a, Fractional b) => a -> b
realToFrac DiffTime
t :: Pico)
formatCharacter False 'S' = (FormatOptions -> DiffTime -> String)
-> Maybe (FormatOptions -> DiffTime -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> DiffTime -> String)
-> Maybe (FormatOptions -> DiffTime -> String))
-> (FormatOptions -> DiffTime -> String)
-> Maybe (FormatOptions -> DiffTime -> String)
forall a b. (a -> b) -> a -> b
$ Int -> (DiffTime -> Integer) -> FormatOptions -> DiffTime -> String
forall t. Int -> (t -> Integer) -> FormatOptions -> t -> String
formatNumberStd 2 ((DiffTime -> Integer) -> FormatOptions -> DiffTime -> String)
-> (DiffTime -> Integer) -> FormatOptions -> DiffTime -> String
forall a b. (a -> b) -> a -> b
$ Integer -> Integer -> Integer
forall a. Real a => a -> a -> a
remBy 60 (Integer -> Integer)
-> (DiffTime -> Integer) -> DiffTime -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DiffTime -> DiffTime -> Integer
forall a b. (Real a, Integral b) => a -> a -> b
quotBy 1
formatCharacter True 'S' = (FormatOptions -> DiffTime -> String)
-> Maybe (FormatOptions -> DiffTime -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> DiffTime -> String)
-> Maybe (FormatOptions -> DiffTime -> String))
-> (FormatOptions -> DiffTime -> String)
-> Maybe (FormatOptions -> DiffTime -> String)
forall a b. (a -> b) -> a -> b
$ Bool
-> Bool
-> Int
-> Char
-> (TimeLocale -> PadOption -> DiffTime -> String)
-> FormatOptions
-> DiffTime
-> String
forall t.
Bool
-> Bool
-> Int
-> Char
-> (TimeLocale -> PadOption -> t -> String)
-> FormatOptions
-> t
-> String
formatGeneral Bool
False Bool
False 12 '0' ((TimeLocale -> PadOption -> DiffTime -> String)
-> FormatOptions -> DiffTime -> String)
-> (TimeLocale -> PadOption -> DiffTime -> String)
-> FormatOptions
-> DiffTime
-> String
forall a b. (a -> b) -> a -> b
$ \_ padf :: PadOption
padf t :: DiffTime
t -> let
padn :: PadOption
padn = case PadOption
padf of
NoPad -> PadOption
NoPad
Pad _ c :: Char
c -> Int -> Char -> PadOption
Pad 2 Char
c
in PadOption -> PadOption -> Pico -> String
forall a.
HasResolution a =>
PadOption -> PadOption -> Fixed a -> String
showPaddedFixed PadOption
padn PadOption
padf (DiffTime -> Pico
forall a b. (Real a, Fractional b) => a -> b
realToFrac (DiffTime -> Pico) -> DiffTime -> Pico
forall a b. (a -> b) -> a -> b
$ DiffTime -> DiffTime -> DiffTime
forall a. Real a => a -> a -> a
remBy 60 DiffTime
t :: Pico)
formatCharacter _ _ = Maybe (FormatOptions -> DiffTime -> String)
forall a. Maybe a
Nothing
instance FormatTime CalendarDiffDays where
formatCharacter :: Bool -> Char -> Maybe (FormatOptions -> CalendarDiffDays -> String)
formatCharacter _ 'y' = (FormatOptions -> CalendarDiffDays -> String)
-> Maybe (FormatOptions -> CalendarDiffDays -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> CalendarDiffDays -> String)
-> Maybe (FormatOptions -> CalendarDiffDays -> String))
-> (FormatOptions -> CalendarDiffDays -> String)
-> Maybe (FormatOptions -> CalendarDiffDays -> String)
forall a b. (a -> b) -> a -> b
$ Int
-> (CalendarDiffDays -> Integer)
-> FormatOptions
-> CalendarDiffDays
-> String
forall t. Int -> (t -> Integer) -> FormatOptions -> t -> String
formatNumberStd 1 ((CalendarDiffDays -> Integer)
-> FormatOptions -> CalendarDiffDays -> String)
-> (CalendarDiffDays -> Integer)
-> FormatOptions
-> CalendarDiffDays
-> String
forall a b. (a -> b) -> a -> b
$ Integer -> Integer -> Integer
forall a b. (Real a, Integral b) => a -> a -> b
quotBy 12 (Integer -> Integer)
-> (CalendarDiffDays -> Integer) -> CalendarDiffDays -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CalendarDiffDays -> Integer
cdMonths
formatCharacter _ 'b' = (FormatOptions -> CalendarDiffDays -> String)
-> Maybe (FormatOptions -> CalendarDiffDays -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> CalendarDiffDays -> String)
-> Maybe (FormatOptions -> CalendarDiffDays -> String))
-> (FormatOptions -> CalendarDiffDays -> String)
-> Maybe (FormatOptions -> CalendarDiffDays -> String)
forall a b. (a -> b) -> a -> b
$ Int
-> (CalendarDiffDays -> Integer)
-> FormatOptions
-> CalendarDiffDays
-> String
forall t. Int -> (t -> Integer) -> FormatOptions -> t -> String
formatNumberStd 1 ((CalendarDiffDays -> Integer)
-> FormatOptions -> CalendarDiffDays -> String)
-> (CalendarDiffDays -> Integer)
-> FormatOptions
-> CalendarDiffDays
-> String
forall a b. (a -> b) -> a -> b
$ CalendarDiffDays -> Integer
cdMonths
formatCharacter _ 'B' = (FormatOptions -> CalendarDiffDays -> String)
-> Maybe (FormatOptions -> CalendarDiffDays -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> CalendarDiffDays -> String)
-> Maybe (FormatOptions -> CalendarDiffDays -> String))
-> (FormatOptions -> CalendarDiffDays -> String)
-> Maybe (FormatOptions -> CalendarDiffDays -> String)
forall a b. (a -> b) -> a -> b
$ Int
-> (CalendarDiffDays -> Integer)
-> FormatOptions
-> CalendarDiffDays
-> String
forall t. Int -> (t -> Integer) -> FormatOptions -> t -> String
formatNumberStd 2 ((CalendarDiffDays -> Integer)
-> FormatOptions -> CalendarDiffDays -> String)
-> (CalendarDiffDays -> Integer)
-> FormatOptions
-> CalendarDiffDays
-> String
forall a b. (a -> b) -> a -> b
$ Integer -> Integer -> Integer
forall a. Real a => a -> a -> a
remBy 12 (Integer -> Integer)
-> (CalendarDiffDays -> Integer) -> CalendarDiffDays -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CalendarDiffDays -> Integer
cdMonths
formatCharacter _ 'w' = (FormatOptions -> CalendarDiffDays -> String)
-> Maybe (FormatOptions -> CalendarDiffDays -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> CalendarDiffDays -> String)
-> Maybe (FormatOptions -> CalendarDiffDays -> String))
-> (FormatOptions -> CalendarDiffDays -> String)
-> Maybe (FormatOptions -> CalendarDiffDays -> String)
forall a b. (a -> b) -> a -> b
$ Int
-> (CalendarDiffDays -> Integer)
-> FormatOptions
-> CalendarDiffDays
-> String
forall t. Int -> (t -> Integer) -> FormatOptions -> t -> String
formatNumberStd 1 ((CalendarDiffDays -> Integer)
-> FormatOptions -> CalendarDiffDays -> String)
-> (CalendarDiffDays -> Integer)
-> FormatOptions
-> CalendarDiffDays
-> String
forall a b. (a -> b) -> a -> b
$ Integer -> Integer -> Integer
forall a b. (Real a, Integral b) => a -> a -> b
quotBy 7 (Integer -> Integer)
-> (CalendarDiffDays -> Integer) -> CalendarDiffDays -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CalendarDiffDays -> Integer
cdDays
formatCharacter _ 'd' = (FormatOptions -> CalendarDiffDays -> String)
-> Maybe (FormatOptions -> CalendarDiffDays -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> CalendarDiffDays -> String)
-> Maybe (FormatOptions -> CalendarDiffDays -> String))
-> (FormatOptions -> CalendarDiffDays -> String)
-> Maybe (FormatOptions -> CalendarDiffDays -> String)
forall a b. (a -> b) -> a -> b
$ Int
-> (CalendarDiffDays -> Integer)
-> FormatOptions
-> CalendarDiffDays
-> String
forall t. Int -> (t -> Integer) -> FormatOptions -> t -> String
formatNumberStd 1 ((CalendarDiffDays -> Integer)
-> FormatOptions -> CalendarDiffDays -> String)
-> (CalendarDiffDays -> Integer)
-> FormatOptions
-> CalendarDiffDays
-> String
forall a b. (a -> b) -> a -> b
$ CalendarDiffDays -> Integer
cdDays
formatCharacter _ 'D' = (FormatOptions -> CalendarDiffDays -> String)
-> Maybe (FormatOptions -> CalendarDiffDays -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> CalendarDiffDays -> String)
-> Maybe (FormatOptions -> CalendarDiffDays -> String))
-> (FormatOptions -> CalendarDiffDays -> String)
-> Maybe (FormatOptions -> CalendarDiffDays -> String)
forall a b. (a -> b) -> a -> b
$ Int
-> (CalendarDiffDays -> Integer)
-> FormatOptions
-> CalendarDiffDays
-> String
forall t. Int -> (t -> Integer) -> FormatOptions -> t -> String
formatNumberStd 1 ((CalendarDiffDays -> Integer)
-> FormatOptions -> CalendarDiffDays -> String)
-> (CalendarDiffDays -> Integer)
-> FormatOptions
-> CalendarDiffDays
-> String
forall a b. (a -> b) -> a -> b
$ Integer -> Integer -> Integer
forall a. Real a => a -> a -> a
remBy 7 (Integer -> Integer)
-> (CalendarDiffDays -> Integer) -> CalendarDiffDays -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CalendarDiffDays -> Integer
cdDays
formatCharacter _ _ = Maybe (FormatOptions -> CalendarDiffDays -> String)
forall a. Maybe a
Nothing
instance FormatTime CalendarDiffTime where
formatCharacter :: Bool -> Char -> Maybe (FormatOptions -> CalendarDiffTime -> String)
formatCharacter _ 'y' = (FormatOptions -> CalendarDiffTime -> String)
-> Maybe (FormatOptions -> CalendarDiffTime -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> CalendarDiffTime -> String)
-> Maybe (FormatOptions -> CalendarDiffTime -> String))
-> (FormatOptions -> CalendarDiffTime -> String)
-> Maybe (FormatOptions -> CalendarDiffTime -> String)
forall a b. (a -> b) -> a -> b
$ Int
-> (CalendarDiffTime -> Integer)
-> FormatOptions
-> CalendarDiffTime
-> String
forall t. Int -> (t -> Integer) -> FormatOptions -> t -> String
formatNumberStd 1 ((CalendarDiffTime -> Integer)
-> FormatOptions -> CalendarDiffTime -> String)
-> (CalendarDiffTime -> Integer)
-> FormatOptions
-> CalendarDiffTime
-> String
forall a b. (a -> b) -> a -> b
$ Integer -> Integer -> Integer
forall a b. (Real a, Integral b) => a -> a -> b
quotBy 12 (Integer -> Integer)
-> (CalendarDiffTime -> Integer) -> CalendarDiffTime -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CalendarDiffTime -> Integer
ctMonths
formatCharacter _ 'b' = (FormatOptions -> CalendarDiffTime -> String)
-> Maybe (FormatOptions -> CalendarDiffTime -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> CalendarDiffTime -> String)
-> Maybe (FormatOptions -> CalendarDiffTime -> String))
-> (FormatOptions -> CalendarDiffTime -> String)
-> Maybe (FormatOptions -> CalendarDiffTime -> String)
forall a b. (a -> b) -> a -> b
$ Int
-> (CalendarDiffTime -> Integer)
-> FormatOptions
-> CalendarDiffTime
-> String
forall t. Int -> (t -> Integer) -> FormatOptions -> t -> String
formatNumberStd 1 ((CalendarDiffTime -> Integer)
-> FormatOptions -> CalendarDiffTime -> String)
-> (CalendarDiffTime -> Integer)
-> FormatOptions
-> CalendarDiffTime
-> String
forall a b. (a -> b) -> a -> b
$ CalendarDiffTime -> Integer
ctMonths
formatCharacter _ 'B' = (FormatOptions -> CalendarDiffTime -> String)
-> Maybe (FormatOptions -> CalendarDiffTime -> String)
forall a. a -> Maybe a
Just ((FormatOptions -> CalendarDiffTime -> String)
-> Maybe (FormatOptions -> CalendarDiffTime -> String))
-> (FormatOptions -> CalendarDiffTime -> String)
-> Maybe (FormatOptions -> CalendarDiffTime -> String)
forall a b. (a -> b) -> a -> b
$ Int
-> (CalendarDiffTime -> Integer)
-> FormatOptions
-> CalendarDiffTime
-> String
forall t. Int -> (t -> Integer) -> FormatOptions -> t -> String
formatNumberStd 2 ((CalendarDiffTime -> Integer)
-> FormatOptions -> CalendarDiffTime -> String)
-> (CalendarDiffTime -> Integer)
-> FormatOptions
-> CalendarDiffTime
-> String
forall a b. (a -> b) -> a -> b
$ Integer -> Integer -> Integer
forall a. Real a => a -> a -> a
remBy 12 (Integer -> Integer)
-> (CalendarDiffTime -> Integer) -> CalendarDiffTime -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CalendarDiffTime -> Integer
ctMonths
formatCharacter alt :: Bool
alt c :: Char
c = ((FormatOptions -> POSIXTime -> String)
-> FormatOptions -> CalendarDiffTime -> String)
-> Maybe (FormatOptions -> POSIXTime -> String)
-> Maybe (FormatOptions -> CalendarDiffTime -> String)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\f :: FormatOptions -> POSIXTime -> String
f fo :: FormatOptions
fo t :: CalendarDiffTime
t -> FormatOptions -> POSIXTime -> String
f FormatOptions
fo (CalendarDiffTime -> POSIXTime
ctTime CalendarDiffTime
t)) (Bool -> Char -> Maybe (FormatOptions -> POSIXTime -> String)
forall t.
FormatTime t =>
Bool -> Char -> Maybe (FormatOptions -> t -> String)
formatCharacter Bool
alt Char
c)