redo formatDate so i can have 12th
This commit is contained in:
parent
fc2185e622
commit
653adfe5fc
1 changed files with 19 additions and 5 deletions
|
@ -10,7 +10,7 @@ import Control.Monad
|
|||
import Data.Maybe (fromMaybe)
|
||||
import qualified Data.Text as Strict
|
||||
import qualified Data.Text.Lazy as Lazy
|
||||
import Data.Time (formatTime, defaultTimeLocale)
|
||||
import qualified Data.Time.Calendar as Time
|
||||
import qualified Data.Char as Char
|
||||
import qualified Data.List as List
|
||||
import System.FilePath (joinPath, splitPath)
|
||||
|
@ -125,10 +125,6 @@ makeDesc nsfw desc nsfwDesc = [b|@4
|
|||
desc' = fromMaybe "" desc
|
||||
nsfwDesc' = fromMaybe "" $ guard nsfw *> nsfwDesc
|
||||
|
||||
formatDate :: Day -> Builder
|
||||
formatDate d =
|
||||
let str = formatTime defaultTimeLocale "%e %#B %Y" d in [b|$@str|]
|
||||
|
||||
makeButtonBar :: Strict.Text -> [Image] -> Builder
|
||||
makeButtonBar title images =
|
||||
case length images of
|
||||
|
@ -201,3 +197,21 @@ extLink (Link {title, url}) = [b|@6
|
|||
$*title
|
||||
</a>
|
||||
|]
|
||||
|
||||
formatDate :: Day -> Builder
|
||||
formatDate date = [b|$*week $day $*month $^year|] where
|
||||
(year, month', day') = Time.toGregorian date
|
||||
week' = Time.dayOfWeek date
|
||||
day = nth day'
|
||||
month = Strict.words "january february march april may june july \
|
||||
\august september october november december"
|
||||
!! (month' - 1)
|
||||
week = Strict.words "mon tue wed thu fri sat sun" !! (fromEnum week' - 1)
|
||||
|
||||
nth :: Int -> Builder
|
||||
nth n = [b|$^n$suf|] where
|
||||
suf | n >= 10, n <= 19 = "th"
|
||||
| n `mod` 10 == 1 = "st"
|
||||
| n `mod` 10 == 2 = "nd"
|
||||
| n `mod` 10 == 3 = "rd"
|
||||
| otherwise = "th"
|
||||
|
|
Loading…
Reference in a new issue