-----------------------------------------------------------------------------
-- |
-- Module      :  Data.HodaTime.Pattern.CalendarDate
-- Copyright   :  (C) 2017 Jason Johnson
-- License     :  BSD-style (see the file LICENSE)
-- Maintainer  :  Jason Johnson <jason.johnson.081@gmail.com>
-- Stability   :  experimental
-- Portability :  POSIX, Windows
--
-- Patterns for a 'Data.HodaTime.CalendarDate.CalendarDate': the standard date layouts (@pd@, @pD@, @pR@) together with
-- the individual field patterns (@pyyyy@, @pMM@, @pMMMM@, @pdd@, @pdddd@ and friends) from which custom date patterns
-- are built.  The primed variants (@pMMMM'@, @pddd'@ …) take a 'Data.HodaTime.Locale.Locale' and use its
-- month\/weekday names.
----------------------------------------------------------------------------
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeOperators #-}
module Data.HodaTime.Pattern.CalendarDate
(
  -- * Standard Patterns
   pd
  ,pD
  ,pR
  ,pmonthDay
  ,pyearMonth
  -- * Custom Patterns
  --
  -- | Used to create specialized patterns.
  ,pyear
  ,pyyyy
  ,pyy
  ,pmonthNum
  ,pMM
  ,pMMM
  ,pMMMM
  ,pMMM'
  ,pMMMM'
  ,pMonthName
  ,pday
  ,pdd
  ,pdaySpace
  ,pddd
  ,pdddd
  ,pddd'
  ,pdddd'
  ,pDayName
)
where

import Data.HodaTime.Pattern.Internal
import Data.HodaTime.CalendarDateTime.Internal (HasDate, Month, MoY, IsCalendar, setMonthIndex, dayOfWeek, DoW)
import qualified Data.HodaTime.CalendarDateTime.Internal as CDT (day, setDay, month, year, setYear)
import qualified  Data.Text as T
import qualified  Data.Text.Lazy.Builder as TLB
import Text.Parsec (choice, try, (<?>))
import Formatting (later)
import Data.HodaTime.Locale.Internal (Locale(..))

-- d1 = maybe (error "duh") id $ calendarDate 1 January 2000
-- d2 = maybe (error "duh") id $ calendarDate 3 March 2020
-- format Data.HodaTime.Pattern.CalendarDate.date d1
-- format Data.HodaTime.Pattern.CalendarDate.date d2
-- parse Data.HodaTime.Pattern.CalendarDate.date "2000/March/01" :: IO (CalendarDate Gregorian)

-- | Absolute year of at least @w@ digits.  Width @1@ is the no-padding case (reads 1-4 digits, so both @"3"@ and
--   @"2020"@ parse; formats with no leading zeros); width @n >= 2@ reads exactly @n@ digits.  The value is always the
--   literal year and is never truncated, so this is the /strict/ counterpart to 'pyy' (which does two-digit century
--   inference).  Values 0-9999 (note: not all dates will be valid in all calendars, if the date is too early it will
--   clamp to earliest valid date)
pyear :: HasDate d => Int -> Pattern (d -> d) (d -> String) String
pyear :: forall d. HasDate d => Int -> Pattern (d -> d) (d -> String) String
pyear Int
w = (d -> Int)
-> (Int -> d -> d)
-> Parser Int String
-> ((d -> Int) -> Format String (d -> String))
-> String
-> Pattern (d -> d) (d -> String) String
forall s a.
(s -> a)
-> (a -> s -> s)
-> Parser a String
-> ((s -> a) -> Format String (s -> String))
-> String
-> Pattern (s -> s) (s -> String) String
pat_field d -> Int
forall d. HasDate d => d -> Int
CDT.year Int -> d -> d
forall d. HasDate d => Int -> d -> d
CDT.setYear (Int -> Int -> Int -> Int -> Parser Int String
pDigits Int
w Int
4 Int
0 Int
9999) (Int -> (d -> Int) -> Format String (d -> String)
forall b a r. Show b => Int -> (a -> b) -> Format r (a -> r)
f_shown_pad Int
w) String
"year: 0-9999"

-- | Absolute year in exactly 4 digits (@'pyear' 4@); values 0000-9999.
pyyyy :: HasDate d => Pattern (d -> d) (d -> String) String
pyyyy :: forall d. HasDate d => Pattern (d -> d) (d -> String) String
pyyyy = Int -> Pattern (d -> d) (d -> String) String
forall d. HasDate d => Int -> Pattern (d -> d) (d -> String) String
pyear Int
4

-- | Two-digit year of the era with the century inferred, mirroring Noda Time's @yy@ specifier (contrast with the
--   strict, absolute 'pyear').  Formatting emits @year `mod` 100@ zero-padded to two digits, so @2020@ becomes @"20"@
--   and @2005@ becomes @"05"@.  Parsing reads exactly two digits and expands them to the year with those final two
--   digits that is closest to the parse /template/ (the default passed to 'parse', whose year is 2000 for the Gregorian
--   epoch), breaking ties toward the future.  With the default template this maps @"20"@ to @2020@ and @"99"@ to
--   @1999@; supply a different template via 'parse'' to slide the 100-year window.
pyy :: HasDate d => Pattern (d -> d) (d -> String) String
pyy :: forall d. HasDate d => Pattern (d -> d) (d -> String) String
pyy = Parser (d -> d) String
-> Format String (d -> String)
-> Pattern (d -> d) (d -> String) String
forall a b r. Parser a r -> Format r b -> Pattern a b r
Pattern Parser (d -> d) String
par Format String (d -> String)
forall {r}. Format r (d -> r)
fmt
  where
    par :: Parser (d -> d) String
par = Int -> d -> d
forall d. HasDate d => Int -> d -> d
expand (Int -> d -> d) -> Parser Int String -> Parser (d -> d) String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> Int -> Int -> Int -> Parser Int String
pDigits Int
2 Int
2 Int
0 Int
99 Parser (d -> d) String -> String -> Parser (d -> d) String
forall s u (m :: * -> *) a.
ParsecT s u m a -> String -> ParsecT s u m a
<?> String
"year: two digits (century inferred)"
    expand :: Int -> d -> d
expand Int
v d
d = Int -> d -> d
forall d. HasDate d => Int -> d -> d
CDT.setYear (Int -> Int -> Int
forall {a}. Integral a => a -> a -> a
fullYear (d -> Int
forall d. HasDate d => d -> Int
CDT.year d
d) Int
v) d
d
    fmt :: Format r (d -> r)
fmt = Int -> (d -> Int) -> Format r (d -> r)
forall b a r. Show b => Int -> (a -> b) -> Format r (a -> r)
f_shown_pad Int
2 (\d
d -> d -> Int
forall d. HasDate d => d -> Int
CDT.year d
d Int -> Int -> Int
forall {a}. Integral a => a -> a -> a
`mod` Int
100)
    fullYear :: a -> a -> a
fullYear a
t a
v = a
base a -> a -> a
forall a. Num a => a -> a -> a
+ a
k a -> a -> a
forall a. Num a => a -> a -> a
* a
100
      where
        base :: a
base = (a
t a -> a -> a
forall {a}. Integral a => a -> a -> a
`div` a
100) a -> a -> a
forall a. Num a => a -> a -> a
* a
100 a -> a -> a
forall a. Num a => a -> a -> a
+ a
v
        k :: a
k = (a
t a -> a -> a
forall a. Num a => a -> a -> a
- a
base a -> a -> a
forall a. Num a => a -> a -> a
+ a
50) a -> a -> a
forall {a}. Integral a => a -> a -> a
`div` a
100

-- | Month of year as a number of @w@ digits, zero-padded; a width of @1@ means /no padding/.  Values 1-12.
pmonthNum :: (HasDate d, Enum (MoY d)) => Int -> Pattern (d -> d) (d -> String) String
pmonthNum :: forall d.
(HasDate d, Enum (MoY d)) =>
Int -> Pattern (d -> d) (d -> String) String
pmonthNum Int
w = (d -> Int)
-> (Int -> d -> d)
-> Parser Int String
-> ((d -> Int) -> Format String (d -> String))
-> String
-> Pattern (d -> d) (d -> String) String
forall s a.
(s -> a)
-> (a -> s -> s)
-> Parser a String
-> ((s -> a) -> Format String (s -> String))
-> String
-> Pattern (s -> s) (s -> String) String
pat_field (MoY d -> Int
forall a. Enum a => a -> Int
fromEnum (MoY d -> Int) -> (d -> MoY d) -> d -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. d -> MoY d
forall d. HasDate d => d -> MoY d
CDT.month) Int -> d -> d
forall d. HasDate d => Int -> d -> d
setMonthIndex (Int -> Int -> Int
forall a. Num a => a -> a -> a
subtract Int
1 (Int -> Int) -> Parser Int String -> Parser Int String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> Int -> Int -> Int -> Parser Int String
pDigits Int
w Int
2 Int
1 Int
12) (d -> Int) -> Format String (d -> String)
fmt String
"month: 1-12"
  where
    fmt :: (d -> Int) -> Format String (d -> String)
fmt d -> Int
x = Int -> (d -> Int) -> Format String (d -> String)
forall b a r. Show b => Int -> (a -> b) -> Format r (a -> r)
f_shown_pad Int
w (Int -> Int
forall a. Enum a => a -> a
succ (Int -> Int) -> (d -> Int) -> d -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. d -> Int
x)

-- | Month of year as a zero-padded number (@'pmonthNum' 2@); values 01-12.
pMM :: (HasDate d, Enum (MoY d)) => Pattern (d -> d) (d -> String) String
pMM :: forall d.
(HasDate d, Enum (MoY d)) =>
Pattern (d -> d) (d -> String) String
pMM = Int -> Pattern (d -> d) (d -> String) String
forall d.
(HasDate d, Enum (MoY d)) =>
Int -> Pattern (d -> d) (d -> String) String
pmonthNum Int
2

-- | Full month name, parsed case-insensitively.  Formats in title case
pMMMM :: forall cal d c. (d ~ c cal, MoY d ~ Month cal, IsCalendar cal, HasDate d, Bounded (Month cal), Read (Month cal), Show (Month cal), Enum (Month cal)) => Pattern (d -> d) (d -> String) String
pMMMM :: forall cal d (c :: * -> *).
(d ~ c cal, MoY d ~ Month cal, IsCalendar cal, HasDate d,
 Bounded (Month cal), Read (Month cal), Show (Month cal),
 Enum (Month cal)) =>
Pattern (d -> d) (d -> String) String
pMMMM = (d -> Int)
-> (Int -> d -> d)
-> Parser Int String
-> ((d -> Int) -> Format String (d -> String))
-> String
-> Pattern (d -> d) (d -> String) String
forall s a.
(s -> a)
-> (a -> s -> s)
-> Parser a String
-> ((s -> a) -> Format String (s -> String))
-> String
-> Pattern (s -> s) (s -> String) String
pat_field (Month cal -> Int
forall a. Enum a => a -> Int
fromEnum (Month cal -> Int) -> (d -> Month cal) -> d -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. d -> MoY d
d -> Month cal
forall d. HasDate d => d -> MoY d
CDT.month) Int -> d -> d
forall d. HasDate d => Int -> d -> d
setMonthIndex Parser Int String
p' (d -> Int) -> Format String (d -> String)
fmt' (String -> Pattern (d -> d) (d -> String) String)
-> String -> Pattern (d -> d) (d -> String) String
forall a b. (a -> b) -> a -> b
$ String
"month: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Month cal -> String
forall a. Show a => a -> String
show Month cal
fm String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"-" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Month cal -> String
forall a. Show a => a -> String
show Month cal
lm
  where
    fm :: Month cal
fm = Month cal
forall a. Bounded a => a
minBound :: Month cal
    lm :: Month cal
lm = Month cal
forall a. Bounded a => a
maxBound :: Month cal
    months :: ParsecT String () Identity String
months = [ParsecT String () Identity String]
-> ParsecT String () Identity String
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice ([ParsecT String () Identity String]
 -> ParsecT String () Identity String)
-> ([Month cal] -> [ParsecT String () Identity String])
-> [Month cal]
-> ParsecT String () Identity String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Month cal -> ParsecT String () Identity String)
-> [Month cal] -> [ParsecT String () Identity String]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (ParsecT String () Identity String
-> ParsecT String () Identity String
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT String () Identity String
 -> ParsecT String () Identity String)
-> (Month cal -> ParsecT String () Identity String)
-> Month cal
-> ParsecT String () Identity String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ParsecT String () Identity String
caseInsensitiveString (String -> ParsecT String () Identity String)
-> (Month cal -> String)
-> Month cal
-> ParsecT String () Identity String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Month cal -> String
forall a. Show a => a -> String
show) ([Month cal] -> ParsecT String () Identity String)
-> [Month cal] -> ParsecT String () Identity String
forall a b. (a -> b) -> a -> b
$ [Month cal
fm..Month cal
lm]
    p' :: Parser Int String
p' = (Month cal -> Int
forall a. Enum a => a -> Int
fromEnum :: Month cal -> Int) (Month cal -> Int) -> (String -> Month cal) -> String -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Month cal
forall a. Read a => String -> a
read (String -> Int)
-> ParsecT String () Identity String -> Parser Int String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT String () Identity String
months
    fmt' :: (d -> Int) -> Format String (d -> String)
fmt' d -> Int
x = (d -> Builder) -> Format String (d -> String)
forall a r. (a -> Builder) -> Format r (a -> r)
later (Text -> Builder
TLB.fromText (Text -> Builder) -> (d -> Text) -> d -> Builder
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
T.pack (String -> Text) -> (d -> String) -> d -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Month cal -> String
forall a. Show a => a -> String
show (Month cal -> String) -> (d -> Month cal) -> d -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int -> Month cal
forall a. Enum a => Int -> a
toEnum :: Int -> Month cal) (Int -> Month cal) -> (d -> Int) -> d -> Month cal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. d -> Int
x)
-- | Abbreviated month name (e.g. @Jan@), parsed case-insensitively and formatted in title case.
--
--   NOTE: the abbreviation is simply the first three letters of the month name, so in calendars where two months share
--   a three-letter prefix (e.g. the Hebrew @AdarI@ and @Adar@) parsing is ambiguous and resolves to the first match in
--   month order.  Use 'pMMMM' (full name) or 'pMM' (number) when you need an unambiguous round-trip.
pMMM :: forall cal d c. (d ~ c cal, MoY d ~ Month cal, IsCalendar cal, HasDate d, Bounded (Month cal), Show (Month cal), Enum (Month cal)) => Pattern (d -> d) (d -> String) String
pMMM :: forall cal d (c :: * -> *).
(d ~ c cal, MoY d ~ Month cal, IsCalendar cal, HasDate d,
 Bounded (Month cal), Show (Month cal), Enum (Month cal)) =>
Pattern (d -> d) (d -> String) String
pMMM = (d -> Int)
-> (Int -> d -> d)
-> Parser Int String
-> ((d -> Int) -> Format String (d -> String))
-> String
-> Pattern (d -> d) (d -> String) String
forall s a.
(s -> a)
-> (a -> s -> s)
-> Parser a String
-> ((s -> a) -> Format String (s -> String))
-> String
-> Pattern (s -> s) (s -> String) String
pat_field (Month cal -> Int
forall a. Enum a => a -> Int
fromEnum (Month cal -> Int) -> (d -> Month cal) -> d -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. d -> MoY d
d -> Month cal
forall d. HasDate d => d -> MoY d
CDT.month) Int -> d -> d
forall d. HasDate d => Int -> d -> d
setMonthIndex Parser Int String
p' (d -> Int) -> Format String (d -> String)
fmt' (String -> Pattern (d -> d) (d -> String) String)
-> String -> Pattern (d -> d) (d -> String) String
forall a b. (a -> b) -> a -> b
$ String
"month: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Month cal -> String
abbr Month cal
fm String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"-" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Month cal -> String
abbr Month cal
lm
  where
    fm :: Month cal
fm = Month cal
forall a. Bounded a => a
minBound :: Month cal
    lm :: Month cal
lm = Month cal
forall a. Bounded a => a
maxBound :: Month cal
    abbr :: Month cal -> String
abbr = Int -> String -> String
forall a. Int -> [a] -> [a]
take Int
3 (String -> String) -> (Month cal -> String) -> Month cal -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Month cal -> String
forall a. Show a => a -> String
show
    p' :: Parser Int String
p' = [Parser Int String] -> Parser Int String
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice ([Parser Int String] -> Parser Int String)
-> ([Month cal] -> [Parser Int String])
-> [Month cal]
-> Parser Int String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Month cal -> Parser Int String)
-> [Month cal] -> [Parser Int String]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Month cal
m -> Month cal -> Int
forall a. Enum a => a -> Int
fromEnum Month cal
m Int -> ParsecT String () Identity String -> Parser Int String
forall a b.
a -> ParsecT String () Identity b -> ParsecT String () Identity a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT String () Identity String
-> ParsecT String () Identity String
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (String -> ParsecT String () Identity String
caseInsensitiveString (Month cal -> String
abbr Month cal
m))) ([Month cal] -> Parser Int String)
-> [Month cal] -> Parser Int String
forall a b. (a -> b) -> a -> b
$ [Month cal
fm..Month cal
lm]
    fmt' :: (d -> Int) -> Format String (d -> String)
fmt' d -> Int
x = (d -> Builder) -> Format String (d -> String)
forall a r. (a -> Builder) -> Format r (a -> r)
later (Text -> Builder
TLB.fromText (Text -> Builder) -> (d -> Text) -> d -> Builder
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
T.pack (String -> Text) -> (d -> String) -> d -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Month cal -> String
abbr (Month cal -> String) -> (d -> Month cal) -> d -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int -> Month cal
forall a. Enum a => Int -> a
toEnum :: Int -> Month cal) (Int -> Month cal) -> (d -> Int) -> d -> Month cal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. d -> Int
x)
-- | Day of month of @w@ digits, zero-padded; a width of @1@ means /no padding/.  Values 1-31.
pday :: HasDate d => Int -> Pattern (d -> d) (d -> String) String
pday :: forall d. HasDate d => Int -> Pattern (d -> d) (d -> String) String
pday Int
w = (d -> Int)
-> (Int -> d -> d)
-> Parser Int String
-> ((d -> Int) -> Format String (d -> String))
-> String
-> Pattern (d -> d) (d -> String) String
forall s a.
(s -> a)
-> (a -> s -> s)
-> Parser a String
-> ((s -> a) -> Format String (s -> String))
-> String
-> Pattern (s -> s) (s -> String) String
pat_field d -> Int
forall d. HasDate d => d -> Int
CDT.day Int -> d -> d
forall d. HasDate d => Int -> d -> d
CDT.setDay (Int -> Int -> Int -> Int -> Parser Int String
pDigits Int
w Int
2 Int
1 Int
31) (Int -> (d -> Int) -> Format String (d -> String)
forall b a r. Show b => Int -> (a -> b) -> Format r (a -> r)
f_shown_pad Int
w) String
"day: 1-31"

-- | Day of month, zero-padded (@'pday' 2@); values 01-31.
pdd :: HasDate d => Pattern (d -> d) (d -> String) String
pdd :: forall d. HasDate d => Pattern (d -> d) (d -> String) String
pdd = Int -> Pattern (d -> d) (d -> String) String
forall d. HasDate d => Int -> Pattern (d -> d) (d -> String) String
pday Int
2

-- | Day of month, /space/-padded to two characters (the @strftime@ @%e@ convention), e.g. @\" 3\"@ or @\"15\"@.  On
--   parse it also accepts the bare and zero-padded forms.
pdaySpace :: HasDate d => Pattern (d -> d) (d -> String) String
pdaySpace :: forall d. HasDate d => Pattern (d -> d) (d -> String) String
pdaySpace = (d -> Int)
-> (Int -> d -> d)
-> Parser Int String
-> ((d -> Int) -> Format String (d -> String))
-> String
-> Pattern (d -> d) (d -> String) String
forall s a.
(s -> a)
-> (a -> s -> s)
-> Parser a String
-> ((s -> a) -> Format String (s -> String))
-> String
-> Pattern (s -> s) (s -> String) String
pat_field d -> Int
forall d. HasDate d => d -> Int
CDT.day Int -> d -> d
forall d. HasDate d => Int -> d -> d
CDT.setDay (Int -> Int -> Int -> Parser Int String
pDigitsSpace Int
2 Int
1 Int
31) (Int -> (d -> Int) -> Format String (d -> String)
forall b a r. Show b => Int -> (a -> b) -> Format r (a -> r)
f_shown_spad Int
2) String
"day: 1-31 (space padded)"

-- | Abbreviated day of week name (e.g. @Mon@), parsed case-insensitively and formatted in title case.  Note: on parse
--   this only /consumes/ the weekday, it is not validated against the day\/month\/year (which fully determine the date).
pddd :: forall d. (HasDate d, Show (DoW d), Enum (DoW d), Bounded (DoW d)) => Pattern (d -> d) (d -> String) String
pddd :: forall d.
(HasDate d, Show (DoW d), Enum (DoW d), Bounded (DoW d)) =>
Pattern (d -> d) (d -> String) String
pddd = Parser (d -> d) String
-> Format String (d -> String)
-> Pattern (d -> d) (d -> String) String
forall a b r. Parser a r -> Format r b -> Pattern a b r
Pattern Parser (d -> d) String
par Format String (d -> String)
fmt
  where
    names :: [DoW d]
names = [DoW d
forall a. Bounded a => a
minBound .. DoW d
forall a. Bounded a => a
maxBound] :: [DoW d]
    abbr :: DoW d -> String
abbr = Int -> String -> String
forall a. Int -> [a] -> [a]
take Int
3 (String -> String) -> (DoW d -> String) -> DoW d -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DoW d -> String
forall a. Show a => a -> String
show
    par :: Parser (d -> d) String
par = d -> d
forall a. a -> a
id (d -> d)
-> ParsecT String () Identity String -> Parser (d -> d) String
forall a b.
a -> ParsecT String () Identity b -> ParsecT String () Identity a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ([ParsecT String () Identity String]
-> ParsecT String () Identity String
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice ([ParsecT String () Identity String]
 -> ParsecT String () Identity String)
-> ([DoW d] -> [ParsecT String () Identity String])
-> [DoW d]
-> ParsecT String () Identity String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (DoW d -> ParsecT String () Identity String)
-> [DoW d] -> [ParsecT String () Identity String]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (ParsecT String () Identity String
-> ParsecT String () Identity String
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT String () Identity String
 -> ParsecT String () Identity String)
-> (DoW d -> ParsecT String () Identity String)
-> DoW d
-> ParsecT String () Identity String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ParsecT String () Identity String
caseInsensitiveString (String -> ParsecT String () Identity String)
-> (DoW d -> String) -> DoW d -> ParsecT String () Identity String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DoW d -> String
abbr) ([DoW d] -> ParsecT String () Identity String)
-> [DoW d] -> ParsecT String () Identity String
forall a b. (a -> b) -> a -> b
$ [DoW d]
names)
    fmt :: Format String (d -> String)
fmt = (d -> Builder) -> Format String (d -> String)
forall a r. (a -> Builder) -> Format r (a -> r)
later (Text -> Builder
TLB.fromText (Text -> Builder) -> (d -> Text) -> d -> Builder
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
T.pack (String -> Text) -> (d -> String) -> d -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DoW d -> String
abbr (DoW d -> String) -> (d -> DoW d) -> d -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. d -> DoW d
forall d. HasDate d => d -> DoW d
dayOfWeek)

-- | Full day of week name (e.g. @Monday@), parsed case-insensitively and formatted in title case.  Note: on parse this
--   only /consumes/ the weekday, it is not validated against the day\/month\/year (which fully determine the date).
pdddd :: forall d. (HasDate d, Show (DoW d), Enum (DoW d), Bounded (DoW d)) => Pattern (d -> d) (d -> String) String
pdddd :: forall d.
(HasDate d, Show (DoW d), Enum (DoW d), Bounded (DoW d)) =>
Pattern (d -> d) (d -> String) String
pdddd = Parser (d -> d) String
-> Format String (d -> String)
-> Pattern (d -> d) (d -> String) String
forall a b r. Parser a r -> Format r b -> Pattern a b r
Pattern Parser (d -> d) String
par Format String (d -> String)
forall {r}. Format r (d -> r)
fmt
  where
    names :: [DoW d]
names = [DoW d
forall a. Bounded a => a
minBound .. DoW d
forall a. Bounded a => a
maxBound] :: [DoW d]
    par :: Parser (d -> d) String
par = d -> d
forall a. a -> a
id (d -> d)
-> ParsecT String () Identity String -> Parser (d -> d) String
forall a b.
a -> ParsecT String () Identity b -> ParsecT String () Identity a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ([ParsecT String () Identity String]
-> ParsecT String () Identity String
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice ([ParsecT String () Identity String]
 -> ParsecT String () Identity String)
-> ([DoW d] -> [ParsecT String () Identity String])
-> [DoW d]
-> ParsecT String () Identity String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (DoW d -> ParsecT String () Identity String)
-> [DoW d] -> [ParsecT String () Identity String]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (ParsecT String () Identity String
-> ParsecT String () Identity String
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT String () Identity String
 -> ParsecT String () Identity String)
-> (DoW d -> ParsecT String () Identity String)
-> DoW d
-> ParsecT String () Identity String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ParsecT String () Identity String
caseInsensitiveString (String -> ParsecT String () Identity String)
-> (DoW d -> String) -> DoW d -> ParsecT String () Identity String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DoW d -> String
forall a. Show a => a -> String
show) ([DoW d] -> ParsecT String () Identity String)
-> [DoW d] -> ParsecT String () Identity String
forall a b. (a -> b) -> a -> b
$ [DoW d]
names)
    fmt :: Format r (d -> r)
fmt = (d -> Builder) -> Format r (d -> r)
forall a r. (a -> Builder) -> Format r (a -> r)
later (Text -> Builder
TLB.fromText (Text -> Builder) -> (d -> Text) -> d -> Builder
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
T.pack (String -> Text) -> (d -> String) -> d -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DoW d -> String
forall a. Show a => a -> String
show (DoW d -> String) -> (d -> DoW d) -> d -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. d -> DoW d
forall d. HasDate d => d -> DoW d
dayOfWeek)

-- | This is the short date pattern, currently defined as "dd/MM/yyyy".
pd :: (HasDate d, Enum (MoY d)) => Pattern (d -> d) (d -> String) String
pd :: forall d.
(HasDate d, Enum (MoY d)) =>
Pattern (d -> d) (d -> String) String
pd = Pattern (d -> d) (d -> String) String
forall d. HasDate d => Pattern (d -> d) (d -> String) String
pdd Pattern (d -> d) (d -> String) String
-> Pattern Char String String
-> Pattern (d -> d) (d -> String) String
forall a b r c. Pattern a b r -> Pattern c r r -> Pattern a b r
<% Char -> Pattern Char String String
char Char
'/' Pattern (d -> d) (d -> String) String
-> Pattern (d -> d) (d -> String) String
-> Pattern (d -> d) (d -> String) String
forall a. Semigroup a => a -> a -> a
<> Pattern (d -> d) (d -> String) String
forall d.
(HasDate d, Enum (MoY d)) =>
Pattern (d -> d) (d -> String) String
pMM Pattern (d -> d) (d -> String) String
-> Pattern Char String String
-> Pattern (d -> d) (d -> String) String
forall a b r c. Pattern a b r -> Pattern c r r -> Pattern a b r
<% Char -> Pattern Char String String
char Char
'/' Pattern (d -> d) (d -> String) String
-> Pattern (d -> d) (d -> String) String
-> Pattern (d -> d) (d -> String) String
forall a. Semigroup a => a -> a -> a
<> Pattern (d -> d) (d -> String) String
forall d. HasDate d => Pattern (d -> d) (d -> String) String
pyyyy

-- | This is the long date pattern, currently defined as "dddd, dd MMMM yyyy".
pD :: (HasDate (c cal), MoY (c cal) ~ Month cal, IsCalendar cal, Bounded (Month cal), Read (Month cal), Show (Month cal), Enum (Month cal), Show (DoW (c cal)), Enum (DoW (c cal)), Bounded (DoW (c cal))) => Pattern (c cal -> c cal) (c cal -> String) String
pD :: forall (c :: * -> *) cal.
(HasDate (c cal), MoY (c cal) ~ Month cal, IsCalendar cal,
 Bounded (Month cal), Read (Month cal), Show (Month cal),
 Enum (Month cal), Show (DoW (c cal)), Enum (DoW (c cal)),
 Bounded (DoW (c cal))) =>
Pattern (c cal -> c cal) (c cal -> String) String
pD = Pattern (c cal -> c cal) (c cal -> String) String
forall d.
(HasDate d, Show (DoW d), Enum (DoW d), Bounded (DoW d)) =>
Pattern (d -> d) (d -> String) String
pdddd Pattern (c cal -> c cal) (c cal -> String) String
-> Pattern String String String
-> Pattern (c cal -> c cal) (c cal -> String) String
forall a b r c. Pattern a b r -> Pattern c r r -> Pattern a b r
<% String -> Pattern String String String
string String
", " Pattern (c cal -> c cal) (c cal -> String) String
-> Pattern (c cal -> c cal) (c cal -> String) String
-> Pattern (c cal -> c cal) (c cal -> String) String
forall a. Semigroup a => a -> a -> a
<> Pattern (c cal -> c cal) (c cal -> String) String
forall d. HasDate d => Pattern (d -> d) (d -> String) String
pdd Pattern (c cal -> c cal) (c cal -> String) String
-> Pattern Char String String
-> Pattern (c cal -> c cal) (c cal -> String) String
forall a b r c. Pattern a b r -> Pattern c r r -> Pattern a b r
<% Char -> Pattern Char String String
char Char
' ' Pattern (c cal -> c cal) (c cal -> String) String
-> Pattern (c cal -> c cal) (c cal -> String) String
-> Pattern (c cal -> c cal) (c cal -> String) String
forall a. Semigroup a => a -> a -> a
<> Pattern (c cal -> c cal) (c cal -> String) String
forall cal d (c :: * -> *).
(d ~ c cal, MoY d ~ Month cal, IsCalendar cal, HasDate d,
 Bounded (Month cal), Read (Month cal), Show (Month cal),
 Enum (Month cal)) =>
Pattern (d -> d) (d -> String) String
pMMMM Pattern (c cal -> c cal) (c cal -> String) String
-> Pattern Char String String
-> Pattern (c cal -> c cal) (c cal -> String) String
forall a b r c. Pattern a b r -> Pattern c r r -> Pattern a b r
<% Char -> Pattern Char String String
char Char
' ' Pattern (c cal -> c cal) (c cal -> String) String
-> Pattern (c cal -> c cal) (c cal -> String) String
-> Pattern (c cal -> c cal) (c cal -> String) String
forall a. Semigroup a => a -> a -> a
<> Pattern (c cal -> c cal) (c cal -> String) String
forall d. HasDate d => Pattern (d -> d) (d -> String) String
pyyyy

-- | The ISO-8601 round-trippable date pattern, "yyyy-MM-dd".
pR :: (HasDate d, Enum (MoY d)) => Pattern (d -> d) (d -> String) String
pR :: forall d.
(HasDate d, Enum (MoY d)) =>
Pattern (d -> d) (d -> String) String
pR = Pattern (d -> d) (d -> String) String
forall d. HasDate d => Pattern (d -> d) (d -> String) String
pyyyy Pattern (d -> d) (d -> String) String
-> Pattern Char String String
-> Pattern (d -> d) (d -> String) String
forall a b r c. Pattern a b r -> Pattern c r r -> Pattern a b r
<% Char -> Pattern Char String String
char Char
'-' Pattern (d -> d) (d -> String) String
-> Pattern (d -> d) (d -> String) String
-> Pattern (d -> d) (d -> String) String
forall a. Semigroup a => a -> a -> a
<> Pattern (d -> d) (d -> String) String
forall d.
(HasDate d, Enum (MoY d)) =>
Pattern (d -> d) (d -> String) String
pMM Pattern (d -> d) (d -> String) String
-> Pattern Char String String
-> Pattern (d -> d) (d -> String) String
forall a b r c. Pattern a b r -> Pattern c r r -> Pattern a b r
<% Char -> Pattern Char String String
char Char
'-' Pattern (d -> d) (d -> String) String
-> Pattern (d -> d) (d -> String) String
-> Pattern (d -> d) (d -> String) String
forall a. Semigroup a => a -> a -> a
<> Pattern (d -> d) (d -> String) String
forall d. HasDate d => Pattern (d -> d) (d -> String) String
pdd

-- | The month-and-day partial pattern (no year), currently "MMMM dd", e.g. @March 03@.
pmonthDay :: (HasDate (c cal), MoY (c cal) ~ Month cal, IsCalendar cal, Bounded (Month cal), Read (Month cal), Show (Month cal), Enum (Month cal)) => Pattern (c cal -> c cal) (c cal -> String) String
pmonthDay :: forall (c :: * -> *) cal.
(HasDate (c cal), MoY (c cal) ~ Month cal, IsCalendar cal,
 Bounded (Month cal), Read (Month cal), Show (Month cal),
 Enum (Month cal)) =>
Pattern (c cal -> c cal) (c cal -> String) String
pmonthDay = Pattern (c cal -> c cal) (c cal -> String) String
forall cal d (c :: * -> *).
(d ~ c cal, MoY d ~ Month cal, IsCalendar cal, HasDate d,
 Bounded (Month cal), Read (Month cal), Show (Month cal),
 Enum (Month cal)) =>
Pattern (d -> d) (d -> String) String
pMMMM Pattern (c cal -> c cal) (c cal -> String) String
-> Pattern Char String String
-> Pattern (c cal -> c cal) (c cal -> String) String
forall a b r c. Pattern a b r -> Pattern c r r -> Pattern a b r
<% Char -> Pattern Char String String
char Char
' ' Pattern (c cal -> c cal) (c cal -> String) String
-> Pattern (c cal -> c cal) (c cal -> String) String
-> Pattern (c cal -> c cal) (c cal -> String) String
forall a. Semigroup a => a -> a -> a
<> Pattern (c cal -> c cal) (c cal -> String) String
forall d. HasDate d => Pattern (d -> d) (d -> String) String
pdd

-- | The year-and-month partial pattern (no day), currently "yyyy MMMM", e.g. @2020 March@.
pyearMonth :: (HasDate (c cal), MoY (c cal) ~ Month cal, IsCalendar cal, Bounded (Month cal), Read (Month cal), Show (Month cal), Enum (Month cal)) => Pattern (c cal -> c cal) (c cal -> String) String
pyearMonth :: forall (c :: * -> *) cal.
(HasDate (c cal), MoY (c cal) ~ Month cal, IsCalendar cal,
 Bounded (Month cal), Read (Month cal), Show (Month cal),
 Enum (Month cal)) =>
Pattern (c cal -> c cal) (c cal -> String) String
pyearMonth = Pattern (c cal -> c cal) (c cal -> String) String
forall d. HasDate d => Pattern (d -> d) (d -> String) String
pyyyy Pattern (c cal -> c cal) (c cal -> String) String
-> Pattern Char String String
-> Pattern (c cal -> c cal) (c cal -> String) String
forall a b r c. Pattern a b r -> Pattern c r r -> Pattern a b r
<% Char -> Pattern Char String String
char Char
' ' Pattern (c cal -> c cal) (c cal -> String) String
-> Pattern (c cal -> c cal) (c cal -> String) String
-> Pattern (c cal -> c cal) (c cal -> String) String
forall a. Semigroup a => a -> a -> a
<> Pattern (c cal -> c cal) (c cal -> String) String
forall cal d (c :: * -> *).
(d ~ c cal, MoY d ~ Month cal, IsCalendar cal, HasDate d,
 Bounded (Month cal), Read (Month cal), Show (Month cal),
 Enum (Month cal)) =>
Pattern (d -> d) (d -> String) String
pMMMM

-- | Format and parse the month using an explicit list of names (index 0 is the calendar's first month), instead of the
--   calendar's built-in English constructor names.  This is the calendar-agnostic core behind the locale-aware 'pMMMM''
--   and 'pMMM''; pass 'Data.HodaTime.Locale.monthNames' (or @monthNamesShort@) for OS locale names, or any list of the
--   right length for a custom calendar.  Parsing is case-insensitive and, like 'pMMMM', tries the names in order.
pMonthName :: (HasDate d, Enum (MoY d)) => [String] -> Pattern (d -> d) (d -> String) String
pMonthName :: forall d.
(HasDate d, Enum (MoY d)) =>
[String] -> Pattern (d -> d) (d -> String) String
pMonthName [String]
names = (d -> Int)
-> (Int -> d -> d)
-> Parser Int String
-> ((d -> Int) -> Format String (d -> String))
-> String
-> Pattern (d -> d) (d -> String) String
forall s a.
(s -> a)
-> (a -> s -> s)
-> Parser a String
-> ((s -> a) -> Format String (s -> String))
-> String
-> Pattern (s -> s) (s -> String) String
pat_field (MoY d -> Int
forall a. Enum a => a -> Int
fromEnum (MoY d -> Int) -> (d -> MoY d) -> d -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. d -> MoY d
forall d. HasDate d => d -> MoY d
CDT.month) Int -> d -> d
forall d. HasDate d => Int -> d -> d
setMonthIndex Parser Int String
par (d -> Int) -> Format String (d -> String)
fmt String
"month name"
  where
    par :: Parser Int String
par = [Parser Int String] -> Parser Int String
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice ([Parser Int String] -> Parser Int String)
-> ([(Int, String)] -> [Parser Int String])
-> [(Int, String)]
-> Parser Int String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Int, String) -> Parser Int String)
-> [(Int, String)] -> [Parser Int String]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(Int
i, String
n) -> Int
i Int -> ParsecT String () Identity String -> Parser Int String
forall a b.
a -> ParsecT String () Identity b -> ParsecT String () Identity a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT String () Identity String
-> ParsecT String () Identity String
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (String -> ParsecT String () Identity String
caseInsensitiveString String
n)) ([(Int, String)] -> Parser Int String)
-> [(Int, String)] -> Parser Int String
forall a b. (a -> b) -> a -> b
$ [Int] -> [String] -> [(Int, String)]
forall a b. [a] -> [b] -> [(a, b)]
zip [Int
0 :: Int ..] [String]
names
    fmt :: (d -> Int) -> Format String (d -> String)
fmt d -> Int
x = (d -> Builder) -> Format String (d -> String)
forall a r. (a -> Builder) -> Format r (a -> r)
later (Text -> Builder
TLB.fromText (Text -> Builder) -> (d -> Text) -> d -> Builder
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
T.pack (String -> Text) -> (d -> String) -> d -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([String]
names [String] -> Int -> String
forall a. HasCallStack => [a] -> Int -> a
!!) (Int -> String) -> (d -> Int) -> d -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. d -> Int
x)

-- | Format and parse the day-of-week using an explicit list of names (index 0 = Sunday), instead of the calendar's
--   built-in English constructor names.  This is the calendar-agnostic core behind 'pdddd'' \/ 'pddd''.  As with
--   'pdddd', parsing only /consumes/ the weekday; it is not validated against the day\/month\/year.
pDayName :: (HasDate d, Enum (DoW d)) => [String] -> Pattern (d -> d) (d -> String) String
pDayName :: forall d.
(HasDate d, Enum (DoW d)) =>
[String] -> Pattern (d -> d) (d -> String) String
pDayName [String]
names = Parser (d -> d) String
-> Format String (d -> String)
-> Pattern (d -> d) (d -> String) String
forall a b r. Parser a r -> Format r b -> Pattern a b r
Pattern Parser (d -> d) String
par Format String (d -> String)
fmt
  where
    par :: Parser (d -> d) String
par = d -> d
forall a. a -> a
id (d -> d)
-> ParsecT String () Identity String -> Parser (d -> d) String
forall a b.
a -> ParsecT String () Identity b -> ParsecT String () Identity a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ([ParsecT String () Identity String]
-> ParsecT String () Identity String
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice ([ParsecT String () Identity String]
 -> ParsecT String () Identity String)
-> ([String] -> [ParsecT String () Identity String])
-> [String]
-> ParsecT String () Identity String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> ParsecT String () Identity String)
-> [String] -> [ParsecT String () Identity String]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (ParsecT String () Identity String
-> ParsecT String () Identity String
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT String () Identity String
 -> ParsecT String () Identity String)
-> (String -> ParsecT String () Identity String)
-> String
-> ParsecT String () Identity String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ParsecT String () Identity String
caseInsensitiveString) ([String] -> ParsecT String () Identity String)
-> [String] -> ParsecT String () Identity String
forall a b. (a -> b) -> a -> b
$ [String]
names)
    fmt :: Format String (d -> String)
fmt = (d -> Builder) -> Format String (d -> String)
forall a r. (a -> Builder) -> Format r (a -> r)
later (Text -> Builder
TLB.fromText (Text -> Builder) -> (d -> Text) -> d -> Builder
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
T.pack (String -> Text) -> (d -> String) -> d -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([String]
names [String] -> Int -> String
forall a. HasCallStack => [a] -> Int -> a
!!) (Int -> String) -> (d -> Int) -> d -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DoW d -> Int
forall a. Enum a => a -> Int
fromEnum (DoW d -> Int) -> (d -> DoW d) -> d -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. d -> DoW d
forall d. HasDate d => d -> DoW d
dayOfWeek)

-- | Full month name in the given 'Locale' (e.g. @März@); the locale-aware counterpart to 'pMMMM'.
pMMMM' :: (HasDate d, Enum (MoY d)) => Locale -> Pattern (d -> d) (d -> String) String
pMMMM' :: forall d.
(HasDate d, Enum (MoY d)) =>
Locale -> Pattern (d -> d) (d -> String) String
pMMMM' = [String] -> Pattern (d -> d) (d -> String) String
forall d.
(HasDate d, Enum (MoY d)) =>
[String] -> Pattern (d -> d) (d -> String) String
pMonthName ([String] -> Pattern (d -> d) (d -> String) String)
-> (Locale -> [String])
-> Locale
-> Pattern (d -> d) (d -> String) String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Locale -> [String]
monthNames

-- | Abbreviated month name in the given 'Locale'; the locale-aware counterpart to 'pMMM'.
pMMM' :: (HasDate d, Enum (MoY d)) => Locale -> Pattern (d -> d) (d -> String) String
pMMM' :: forall d.
(HasDate d, Enum (MoY d)) =>
Locale -> Pattern (d -> d) (d -> String) String
pMMM' = [String] -> Pattern (d -> d) (d -> String) String
forall d.
(HasDate d, Enum (MoY d)) =>
[String] -> Pattern (d -> d) (d -> String) String
pMonthName ([String] -> Pattern (d -> d) (d -> String) String)
-> (Locale -> [String])
-> Locale
-> Pattern (d -> d) (d -> String) String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Locale -> [String]
monthNamesShort

-- | Full weekday name in the given 'Locale' (e.g. @Sonntag@); the locale-aware counterpart to 'pdddd'.
pdddd' :: (HasDate d, Enum (DoW d)) => Locale -> Pattern (d -> d) (d -> String) String
pdddd' :: forall d.
(HasDate d, Enum (DoW d)) =>
Locale -> Pattern (d -> d) (d -> String) String
pdddd' = [String] -> Pattern (d -> d) (d -> String) String
forall d.
(HasDate d, Enum (DoW d)) =>
[String] -> Pattern (d -> d) (d -> String) String
pDayName ([String] -> Pattern (d -> d) (d -> String) String)
-> (Locale -> [String])
-> Locale
-> Pattern (d -> d) (d -> String) String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Locale -> [String]
dayNames

-- | Abbreviated weekday name in the given 'Locale'; the locale-aware counterpart to 'pddd'.
pddd' :: (HasDate d, Enum (DoW d)) => Locale -> Pattern (d -> d) (d -> String) String
pddd' :: forall d.
(HasDate d, Enum (DoW d)) =>
Locale -> Pattern (d -> d) (d -> String) String
pddd' = [String] -> Pattern (d -> d) (d -> String) String
forall d.
(HasDate d, Enum (DoW d)) =>
[String] -> Pattern (d -> d) (d -> String) String
pDayName ([String] -> Pattern (d -> d) (d -> String) String)
-> (Locale -> [String])
-> Locale
-> Pattern (d -> d) (d -> String) String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Locale -> [String]
dayNamesShort