herf-time-0.3.0: haskell time manipulation in a 'kerf like' style.

Safe HaskellNone
LanguageHaskell2010

HerfTime

Description

The Herf Time package is loosely based on the Kerf programming language's approach to time. https://github.com/kevinlawler/kerf

Where it made sense to do things differently it does.

The fundamental engine is the typeclass HerfTime

Synopsis

Documentation

module Data.Time

herfShow :: (HerfedTime t, FormatTime t) => t -> String Source #

Display herf times in a pre formatted way

reherf :: (ToUTCHerfTime a, ToUTCHerfTime b, FromUTCHerfTime a, FromUTCHerfTime b) => a -> b Source #

reherf is not part of a typeclass, just more sugar to make dealing with time conversion If both classes are defined on the same type, the classes should round trip. e.g. (date y m d ):: UTCTime in d == (reherf d))

getYear :: UTCTime -> Integer Source #

getYear someUtcTime -> 2016y

getMonth :: UTCTime -> Integer Source #

getMonth someUtcTime -> 10m

getDay :: UTCTime -> Integer Source #

getDay someUtcTime -> 31d

getDateParts :: UTCTime -> (Integer, Integer, Integer) Source #

Get all date parts together

getHour :: UTCTime -> Integer Source #

getHour someUtcTime -> 1h

getMin :: UTCTime -> Integer Source #

getMin someUtcTime -> 37i

getSeconds :: UTCTime -> Integer Source #

getSeconds someUtcTime -> 1s

getPicoseconds :: UTCTime -> Integer Source #

getPicoseconds somUTCTime -> 1ps

data UTCHerfTime Source #

Below are the classes that make up the core of the HerfTime Library. Starting with the type UTCHerfTime which is the encoding that most other time stamps pass through

Instances
Eq UTCHerfTime Source # 
Instance details

Defined in HerfTime

Ord UTCHerfTime Source # 
Instance details

Defined in HerfTime

Show UTCHerfTime Source # 
Instance details

Defined in HerfTime

FormatTime UTCHerfTime Source # 
Instance details

Defined in HerfTime

HerfedTime UTCHerfTime Source # 
Instance details

Defined in HerfTime

FromUTCHerfTime UTCHerfTime Source # 
Instance details

Defined in HerfTime

ToUTCHerfTime UTCHerfTime Source #

NominalHerf time will obey the laws of HerfedTime by default

Instance details

Defined in HerfTime

class (ToUTCHerfTime a, FromUTCHerfTime a) => HerfedTime a where Source #

This defines the time language of herf the important rule here is path independence (unherf $ (herf a) add i ) == (a add i)

This ensures that regardless of how you get to a time the result will be the same

Something to notice is that rule still allows for lossy Time Stamps. The loss just has to be captured uniformally in the transforms and the interval arithmetic

Instances
HerfedTime UTCTime Source #

Get Times in any viable format (UTC for example) >>> unherf $ date 2016 01 01 add hour 3 add week 16 add month 3 :: UTCTime 2016-07-22 03:00:00 UTC

Instance details

Defined in HerfTime

HerfedTime UTCHerfTime Source # 
Instance details

Defined in HerfTime

KnownSymbol z => HerfedTime (HerfZonedTime z) Source #
>>> :set -XDataKinds
>>> (reherf $ ( dateTime 2016 01 01 01 01 01 :: HerfZonedTime "CST")) :: HerfZonedTime "PST"
2015-12-31T23:01:01:PST
Instance details

Defined in HerfTime.ZonedTime

class ToUTCHerfTime a where Source #

The ToUTCHerfTime is necessary to have an interface lifted so that all the functions can be abstracted over it

Methods

herf :: a -> UTCHerfTime Source #

Instances
ToUTCHerfTime UTCTime Source #

UTCTime is the underlying and most important HerfTime thing

Instance details

Defined in HerfTime

ToUTCHerfTime UTCHerfTime Source #

NominalHerf time will obey the laws of HerfedTime by default

Instance details

Defined in HerfTime

KnownSymbol z => ToUTCHerfTime (HerfZonedTime z) Source # 
Instance details

Defined in HerfTime.ZonedTime

class FromUTCHerfTime a where Source #

come back from the UTCHerfTime universal represenation

Methods

unherf :: UTCHerfTime -> a Source #

Instances
FromUTCHerfTime UTCTime Source # 
Instance details

Defined in HerfTime

FromUTCHerfTime UTCHerfTime Source # 
Instance details

Defined in HerfTime

KnownSymbol z => FromUTCHerfTime (HerfZonedTime z) Source # 
Instance details

Defined in HerfTime.ZonedTime

class HerfAdd a where Source #

This provides the unified interface to herfed times. All instances of this class should obey the rule that if some interval you are adding is equivalent in another HerfAdd time then there should be no difference between adding that many to a HerfedTime i.e. (HerfMin 1) == (HerfSec 60) (herf $ add someTime (HerfMin 1) ) == (herf $ add someTime (HerfMin 60))

Methods

add :: HerfedTime t => t -> a -> t Source #

Instances
HerfAdd HerfPico Source # 
Instance details

Defined in HerfTime

Methods

add :: HerfedTime t => t -> HerfPico -> t Source #

HerfAdd HerfSec Source # 
Instance details

Defined in HerfTime

Methods

add :: HerfedTime t => t -> HerfSec -> t Source #

HerfAdd HerfMin Source # 
Instance details

Defined in HerfTime

Methods

add :: HerfedTime t => t -> HerfMin -> t Source #

HerfAdd HerfHour Source # 
Instance details

Defined in HerfTime

Methods

add :: HerfedTime t => t -> HerfHour -> t Source #

HerfAdd HerfDay Source # 
Instance details

Defined in HerfTime

Methods

add :: HerfedTime t => t -> HerfDay -> t Source #

HerfAdd HerfWeek Source # 
Instance details

Defined in HerfTime

Methods

add :: HerfedTime t => t -> HerfWeek -> t Source #

HerfAdd HerfMonth Source # 
Instance details

Defined in HerfTime

Methods

add :: HerfedTime t => t -> HerfMonth -> t Source #

HerfAdd HerfYear Source # 
Instance details

Defined in HerfTime

Methods

add :: HerfedTime t => t -> HerfYear -> t Source #

data HerfYear Source #

Simple representation of a time interval of a year

Instances
Eq HerfYear Source # 
Instance details

Defined in HerfTime

Num HerfYear Source # 
Instance details

Defined in HerfTime

Ord HerfYear Source # 
Instance details

Defined in HerfTime

Show HerfYear Source # 
Instance details

Defined in HerfTime

HerfAdd HerfYear Source # 
Instance details

Defined in HerfTime

Methods

add :: HerfedTime t => t -> HerfYear -> t Source #

data HerfMonth Source #

Simple representation of a time interval of a month

Instances
Eq HerfMonth Source # 
Instance details

Defined in HerfTime

Num HerfMonth Source # 
Instance details

Defined in HerfTime

Ord HerfMonth Source # 
Instance details

Defined in HerfTime

Show HerfMonth Source # 
Instance details

Defined in HerfTime

HerfAdd HerfMonth Source # 
Instance details

Defined in HerfTime

Methods

add :: HerfedTime t => t -> HerfMonth -> t Source #

data HerfWeek Source #

Simple representation of a time interval of a week

Instances
Eq HerfWeek Source # 
Instance details

Defined in HerfTime

Num HerfWeek Source # 
Instance details

Defined in HerfTime

Ord HerfWeek Source # 
Instance details

Defined in HerfTime

Show HerfWeek Source # 
Instance details

Defined in HerfTime

HerfAdd HerfWeek Source # 
Instance details

Defined in HerfTime

Methods

add :: HerfedTime t => t -> HerfWeek -> t Source #

data HerfDay Source #

Simple representation of a time interval of a day

Instances
Eq HerfDay Source # 
Instance details

Defined in HerfTime

Methods

(==) :: HerfDay -> HerfDay -> Bool #

(/=) :: HerfDay -> HerfDay -> Bool #

Num HerfDay Source # 
Instance details

Defined in HerfTime

Ord HerfDay Source # 
Instance details

Defined in HerfTime

Show HerfDay Source # 
Instance details

Defined in HerfTime

HerfAdd HerfDay Source # 
Instance details

Defined in HerfTime

Methods

add :: HerfedTime t => t -> HerfDay -> t Source #

data HerfHour Source #

Simple representation of a time interval of a hour

Instances
Eq HerfHour Source # 
Instance details

Defined in HerfTime

Num HerfHour Source # 
Instance details

Defined in HerfTime

Ord HerfHour Source # 
Instance details

Defined in HerfTime

Show HerfHour Source # 
Instance details

Defined in HerfTime

HerfAdd HerfHour Source # 
Instance details

Defined in HerfTime

Methods

add :: HerfedTime t => t -> HerfHour -> t Source #

data HerfMin Source #

Simple representation of a time interval of a minute

Instances
Eq HerfMin Source # 
Instance details

Defined in HerfTime

Methods

(==) :: HerfMin -> HerfMin -> Bool #

(/=) :: HerfMin -> HerfMin -> Bool #

Num HerfMin Source # 
Instance details

Defined in HerfTime

Ord HerfMin Source # 
Instance details

Defined in HerfTime

Show HerfMin Source # 
Instance details

Defined in HerfTime

HerfAdd HerfMin Source # 
Instance details

Defined in HerfTime

Methods

add :: HerfedTime t => t -> HerfMin -> t Source #

data HerfSec Source #

Simple representation of a time interval of a second

Instances
Eq HerfSec Source # 
Instance details

Defined in HerfTime

Methods

(==) :: HerfSec -> HerfSec -> Bool #

(/=) :: HerfSec -> HerfSec -> Bool #

Num HerfSec Source # 
Instance details

Defined in HerfTime

Ord HerfSec Source # 
Instance details

Defined in HerfTime

Show HerfSec Source # 
Instance details

Defined in HerfTime

HerfAdd HerfSec Source # 
Instance details

Defined in HerfTime

Methods

add :: HerfedTime t => t -> HerfSec -> t Source #

data HerfPico Source #

Simple representation of a time interval of a picosecond

Instances
Eq HerfPico Source # 
Instance details

Defined in HerfTime

Num HerfPico Source # 
Instance details

Defined in HerfTime

Ord HerfPico Source # 
Instance details

Defined in HerfTime

Show HerfPico Source # 
Instance details

Defined in HerfTime

HerfAdd HerfPico Source # 
Instance details

Defined in HerfTime

Methods

add :: HerfedTime t => t -> HerfPico -> t Source #

year :: Integer -> HerfYear Source #

Add Intervals of different amounts

>>> date 2016 01 01 `add` hour 3 `add` week 16 `add` month 3 :: UTCHerfTime
UTCHerfTime 2016-07-22 03:00:00 UTC

Represent Time in a few different ways

>>> dateTime 2016 01 01 01 23 01 `add` (hour 3) `add` (week 16) `add` (month 3) :: UTCHerfTime
UTCHerfTime 2016-07-22 04:23:01 UTC
>>> dateTimePico 2016 01 01 01 23 01 01 `add` (hour 3) `add` (week 16) `add` (month 3) :: UTCHerfTime
UTCHerfTime 2016-07-22 04:23:01.000000000001 UTC

Use negative signs to subtract

>>> date 2016 01 01 `add` hour (-3) `add` week (-16) `add` month (-3) :: UTCHerfTime
UTCHerfTime 2015-06-10 21:00:00 UTC

Interface functions following Kerf y