]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Text/Corpus/Parsers/Date/Attoparsec.hs
[Community] specs + database schema adapted to link doc/contact
[gargantext.git] / src / Gargantext / Text / Corpus / Parsers / Date / Attoparsec.hs
1 {-|
2 Module : Gargantext.Text.Corpus.Parsers.Date.Attoparsec
3 Description :
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
8 Portability : POSIX
9
10
11 -}
12
13
14 module Gargantext.Text.Corpus.Parsers.Date.Attoparsec
15 where
16
17 import Control.Applicative ((<*))
18 import Data.Attoparsec.ByteString (Parser, take)
19 import Data.ByteString (ByteString)
20 import Data.Monoid ((<>))
21 import Data.Tuple.Extra (first)
22 import Gargantext.Prelude hiding (takeWhile, take)
23
24 -------------------------------------------------------------
25
26 parserWith :: Parser ByteString -> Parser [(ByteString, ByteString)]
27 parserWith sep = do
28 day <- take 2 <* sep
29 mon <- take 2 <* sep
30 yea <- take 4
31 pure $ map (first (\x -> "publication_" <> x))
32 [ ("day",day)
33 , ("month", mon)
34 , ("year", yea)
35 , ("date", yea <> "-" <> mon <> "-" <> day <> "T0:0:0")
36 ]
37