]> Git — Sourcephile - gargantext.git/blob - src/Data/Gargantext/Utils/DateUtils.hs
[FIX] hpack-convert for automatic gargantext.cabal updates (thx yann).
[gargantext.git] / src / Data / Gargantext / Utils / DateUtils.hs
1 module Data.Gargantext.Utils.DateUtils where
2
3 import Data.Time (UTCTime, toGregorian, utctDay)
4
5 --
6 --readInt :: IO [Char] -> IO Int
7 --readInt = readLn
8 --
9 --readBool :: IO [Char] -> IO Bool
10 --readBool = readLn
11
12 utc2gregorian :: UTCTime -> (Integer, Int, Int)
13 utc2gregorian date = toGregorian $ utctDay date
14
15 gregorian2year :: (Integer, Int, Int) -> Integer
16 gregorian2year (y, _m, _d) = y
17
18 utc2year :: UTCTime -> Integer
19 utc2year date = gregorian2year $ utc2gregorian date
20
21 averageLength :: Fractional a => [[a1]] -> a
22 averageLength l = fromIntegral (sum (map length l)) / fromIntegral (length l)
23
24 --main :: IO ()
25 --main = do
26 -- c <- getCurrentTime
27 -- print c -- $ toYear $ toGregorian $ utctDay c
28
29 charToString :: Char -> String
30 charToString = (:[])