]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Core/Utils/DateUtils.hs
[TOOLS] WIP getting NodeListStory
[gargantext.git] / src / Gargantext / Core / Utils / DateUtils.hs
1 {-|
2 Module : Gargantext.Core.Utils.DateUtils
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 module Gargantext.Core.Utils.DateUtils where
13
14 import Gargantext.Prelude
15 import Data.Time (UTCTime, toGregorian, utctDay)
16
17 --
18 --readInt :: IO [Char] -> IO Int
19 --readInt = readLn
20 --
21 --readBool :: IO [Char] -> IO Bool
22 --readBool = readLn
23
24 utc2gregorian :: UTCTime -> (Integer, Int, Int)
25 utc2gregorian date = toGregorian $ utctDay date
26
27 gregorian2year :: (Integer, Int, Int) -> Integer
28 gregorian2year (y, _m, _d) = y
29
30 utc2year :: UTCTime -> Integer
31 utc2year date = gregorian2year $ utc2gregorian date
32
33 averageLength :: Fractional a => [[a1]] -> a
34 averageLength l = fromIntegral (sum (map length l)) / fromIntegral (length l)
35
36 --main :: IO ()
37 --main = do
38 -- c <- getCurrentTime
39 -- print c -- $ toYear $ toGregorian $ utctDay c
40