Basic TimeEvent support for 'hourglass', will need this for 'hit'

This commit is contained in:
fr33domlover 2016-05-05 23:05:56 +00:00
parent ebbcc6afdc
commit 96d73f3551
2 changed files with 37 additions and 0 deletions

View file

@ -0,0 +1,36 @@
{- This file is part of Vervis.
-
- Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
-
- Copying is an act of love. Please copy, reuse and share.
-
- The author(s) have dedicated all copyright and related and neighboring
- rights to this software to the public domain worldwide. This software is
- distributed without any warranty.
-
- You should have received a copy of the CC0 Public Domain Dedication along
- with this software. If not, see
- <http://creativecommons.org/publicdomain/zero/1.0/>.
-}
module Data.Hourglass.Local
(
)
where
import Prelude
import Data.Hourglass
import Data.EventTime.Local
instance IntervalToEventTime Seconds where
intervalToEventTime s
| s < 0 = Never
| s == 0 = Now
| s < 60 * 60 = Ago $ TimeAgo Second si
| s < 60 * 60 * 24 = Ago $ TimeAgo Minute $ si `div` 60
| s < 60 * 60 * 24 * 365 = Ago $ TimeAgo Hour $ si `div` (60 * 60)
| otherwise = Ago $ TimeAgo Day $ si `div` (60 * 60 * 24)
where
si = fromIntegral s

View file

@ -41,6 +41,7 @@ library
Data.Char.Local
Data.EventTime.Local
Data.Git.Local
Data.Hourglass.Local
Data.List.Local
Network.SSH.Local
Text.FilePath.Local