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