From 96d73f3551bf98723c48eeb234b9ec2cf1887b71 Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Thu, 5 May 2016 23:05:56 +0000 Subject: [PATCH] Basic TimeEvent support for 'hourglass', will need this for 'hit' --- src/Data/Hourglass/Local.hs | 36 ++++++++++++++++++++++++++++++++++++ vervis.cabal | 1 + 2 files changed, 37 insertions(+) create mode 100644 src/Data/Hourglass/Local.hs diff --git a/src/Data/Hourglass/Local.hs b/src/Data/Hourglass/Local.hs new file mode 100644 index 0000000..be0d1a8 --- /dev/null +++ b/src/Data/Hourglass/Local.hs @@ -0,0 +1,36 @@ +{- This file is part of Vervis. + - + - Written in 2016 by fr33domlover . + - + - ♡ 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 + - . + -} + +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 diff --git a/vervis.cabal b/vervis.cabal index bd05eb4..03aa945 100644 --- a/vervis.cabal +++ b/vervis.cabal @@ -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