]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Text/Corpus/Parsers/Date/Attoparsec.hs
[GRAPH] adding type Ordering to sortTficf and others
[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 {-# LANGUAGE NoImplicitPrelude #-}
14 {-# LANGUAGE OverloadedStrings #-}
15
16 module Gargantext.Text.Corpus.Parsers.Date.Attoparsec
17 where
18
19 import Control.Applicative ((<*))
20 import Data.Attoparsec.ByteString (Parser, take)
21 import Data.ByteString (ByteString)
22 import Data.Monoid ((<>))
23 import Data.Tuple.Extra (first)
24 import Gargantext.Prelude hiding (takeWhile, take)
25
26 -------------------------------------------------------------
27
28 parserWith :: Parser ByteString -> Parser [(ByteString, ByteString)]
29 parserWith sep = do
30 day <- take 2 <* sep
31 mon <- take 2 <* sep
32 yea <- take 4
33 pure $ map (first (\x -> "publication_" <> x))
34 [ ("day",day)
35 , ("month", mon)
36 , ("year", yea)
37 , ("date", yea <> "-" <> mon <> "-" <> day <> "T0:0:0")
38 ]
39