mirror of https://github.com/voidlizard/hbs2
strftime
This commit is contained in:
parent
80f503c873
commit
27ac86cdfd
|
@ -51,6 +51,8 @@ import Data.Text (Text)
|
||||||
import Data.Text.Encoding (decodeUtf8With)
|
import Data.Text.Encoding (decodeUtf8With)
|
||||||
import Data.Text.Encoding.Error (ignore)
|
import Data.Text.Encoding.Error (ignore)
|
||||||
import Data.Time.Clock.POSIX
|
import Data.Time.Clock.POSIX
|
||||||
|
import Data.Time.Format (defaultTimeLocale, formatTime)
|
||||||
|
|
||||||
import HTMLEntities.Text as Html
|
import HTMLEntities.Text as Html
|
||||||
import GHC.Generics hiding (C)
|
import GHC.Generics hiding (C)
|
||||||
import Prettyprinter
|
import Prettyprinter
|
||||||
|
@ -1465,6 +1467,10 @@ internalEntries = do
|
||||||
entry $ bindMatch "sym" atomFrom
|
entry $ bindMatch "sym" atomFrom
|
||||||
entry $ bindMatch "atom" atomFrom
|
entry $ bindMatch "atom" atomFrom
|
||||||
|
|
||||||
|
entry $ bindMatch "int" $ \case
|
||||||
|
[ StringLike x ] -> pure $ maybe nil mkInt (readMay x)
|
||||||
|
_ -> pure nil
|
||||||
|
|
||||||
entry $ bindMatch "str" $ \case
|
entry $ bindMatch "str" $ \case
|
||||||
[] -> pure $ mkStr ""
|
[] -> pure $ mkStr ""
|
||||||
[x] -> pure $ mkStr (show $ pretty x)
|
[x] -> pure $ mkStr (show $ pretty x)
|
||||||
|
@ -1742,6 +1748,15 @@ internalEntries = do
|
||||||
_ -> throwIO $ BadFormException @c nil
|
_ -> throwIO $ BadFormException @c nil
|
||||||
|
|
||||||
|
|
||||||
|
entry $ bindMatch "strftime" $ \case
|
||||||
|
[ StringLike fmt, LitIntVal t ] -> do
|
||||||
|
let utcTime = posixSecondsToUTCTime (fromIntegral t)
|
||||||
|
formattedTime = formatTime defaultTimeLocale fmt utcTime
|
||||||
|
pure $ mkStr formattedTime
|
||||||
|
|
||||||
|
_ -> throwIO $ BadFormException @c nil
|
||||||
|
|
||||||
|
|
||||||
entry $ bindMatch "css" $ \case
|
entry $ bindMatch "css" $ \case
|
||||||
[ sel, ListVal kwa ] -> do
|
[ sel, ListVal kwa ] -> do
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue