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
11 {-# LANGUAGE NoImplicitPrelude #-}
13 module Gargantext.Core.Utils.DateUtils where
15 import Gargantext.Prelude
16 import Data.Time (UTCTime, toGregorian, utctDay)
19 --readInt :: IO [Char] -> IO Int
22 --readBool :: IO [Char] -> IO Bool
25 utc2gregorian :: UTCTime -> (Integer, Int, Int)
26 utc2gregorian date = toGregorian $ utctDay date
28 gregorian2year :: (Integer, Int, Int) -> Integer
29 gregorian2year (y, _m, _d) = y
31 utc2year :: UTCTime -> Integer
32 utc2year date = gregorian2year $ utc2gregorian date
34 averageLength :: Fractional a => [[a1]] -> a
35 averageLength l = fromIntegral (sum (map length l)) / fromIntegral (length l)
39 -- c <- getCurrentTime
40 -- print c -- $ toYear $ toGregorian $ utctDay c