2 Module : Gargantext.Core.Utils.DateUtils
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
12 module Gargantext.Core.Utils.DateUtils where
14 import Gargantext.Prelude
15 import Data.Time (UTCTime, toGregorian, utctDay)
18 --readInt :: IO [Char] -> IO Int
21 --readBool :: IO [Char] -> IO Bool
24 utc2gregorian :: UTCTime -> (Integer, Int, Int)
25 utc2gregorian date = toGregorian $ utctDay date
27 gregorian2year :: (Integer, Int, Int) -> Integer
28 gregorian2year (y, _m, _d) = y
30 utc2year :: UTCTime -> Integer
31 utc2year date = gregorian2year $ utc2gregorian date
33 averageLength :: Fractional a => [[a1]] -> a
34 averageLength l = fromIntegral (sum (map length l)) / fromIntegral (length l)
38 -- c <- getCurrentTime
39 -- print c -- $ toYear $ toGregorian $ utctDay c