module Vimeta.UI.Common.Util
( parens,
dayAsYear,
dayRange,
)
where
import Data.Time (Day, defaultTimeLocale, formatTime)
parens :: Text -> Text
parens :: Text -> Text
parens Text
t = Text
" (" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
t Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
")"
dayAsYear :: Maybe Day -> Text
dayAsYear :: Maybe Day -> Text
dayAsYear Maybe Day
Nothing = Text
"----"
dayAsYear (Just Day
d) = String -> Text
forall a. ToText a => a -> Text
toText (TimeLocale -> String -> Day -> String
forall t. FormatTime t => TimeLocale -> String -> t -> String
formatTime TimeLocale
defaultTimeLocale String
"%Y" Day
d)
dayRange :: Maybe Day -> Maybe Day -> Text
dayRange :: Maybe Day -> Maybe Day -> Text
dayRange Maybe Day
d1 Maybe Day
d2 = Maybe Day -> Text
dayAsYear Maybe Day
d1 Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" - " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Maybe Day -> Text
dayAsYear Maybe Day
d2