time-lens-0.4.0.1: Lens-based interface to Data.Time data structures

Safe HaskellNone
LanguageHaskell98

Data.Time.Lens

Contents

Synopsis

Time

The semantics of getL for time lenses (time,hours,minutes,seconds) is straightforward.

The semantics of setL is to «normalize» the time before setting. Hence modL minutes (+5) will correctly add 5 minutes to the time, e.g.

>>> modL minutes (+5) (TimeOfDay 16 57 13)
17:02:13

If this means crossing a day boundary, the semantics varies for different structures. For structures that have a date component (i.e. for instances of HasDate) the date is adjusted appropriately.

>>> modL hours (+10) (LocalTime (fromGregorian 2012 05 23) (TimeOfDay 16 57 13))
2012-05-24 02:57:13
>>> modL seconds (subtract 1) (LocalTime (fromGregorian 2012 05 23) (TimeOfDay 0 0 0))
2012-05-22 23:59:59

If there's no date, the time is simply wrapped around.

>>> modL seconds (subtract 1) (TimeOfDay 0 0 0)
23:59:59

class HasTime a where #

Minimal complete definition

time

Methods

time :: Lens a TimeOfDay #

hours :: HasTime a => Lens a Int #

Date

In contrast to time, the date lens is a simple accessor (it doesn't make sense to «normalize» a Day).

Instead, setters for year, month and day have special semantics described below. Getters are always straightforward.

class HasDate a where #

Minimal complete definition

date

Methods

date :: Lens a Day #

year :: HasDate a => Lens a Integer #

modL year (+n) adds n years, matching month and day, with Feb 29th rolled over to Mar 1st if necessary (like addGregorianYearsRollOver)

month :: HasDate a => Lens a Int #

modL month (+n) adds n months, with days past the last day of the month rolling over to the next month (like addGregorianMonthsRollOver)

day :: HasDate a => Lens a Int #

modL day (+n) computes the date n days after the original date (like addDays)

gregorian :: HasDate a => Lens a (Integer, Int, Int) #

The semantics of gregorian corresponds to that of toGregorian and fromGregorian

Time zone

Getting timeZone is straightforward. Setting TimeZone changes both timeZone and time (and date, if present) in such a way that the new zoned time corresponds to the same UTC time as the original zoned time.

class HasTime a => HasTimeZone a where #

Minimal complete definition

timeZone

Methods

timeZone :: Lens a TimeZone #

Re-exports from Data.Time

data Day :: * #

The Modified Julian Day is a standard count of days, with zero being the day 1858-11-17.

Instances

Enum Day 

Methods

succ :: Day -> Day #

pred :: Day -> Day #

toEnum :: Int -> Day #

fromEnum :: Day -> Int #

enumFrom :: Day -> [Day] #

enumFromThen :: Day -> Day -> [Day] #

enumFromTo :: Day -> Day -> [Day] #

enumFromThenTo :: Day -> Day -> Day -> [Day] #

Eq Day 

Methods

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

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

Data Day 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Day -> c Day #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Day #

toConstr :: Day -> Constr #

dataTypeOf :: Day -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Day) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Day) #

gmapT :: (forall b. Data b => b -> b) -> Day -> Day #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Day -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Day -> r #

gmapQ :: (forall d. Data d => d -> u) -> Day -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Day -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Day -> m Day #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Day -> m Day #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Day -> m Day #

Ord Day 

Methods

compare :: Day -> Day -> Ordering #

(<) :: Day -> Day -> Bool #

(<=) :: Day -> Day -> Bool #

(>) :: Day -> Day -> Bool #

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

max :: Day -> Day -> Day #

min :: Day -> Day -> Day #

Ix Day 

Methods

range :: (Day, Day) -> [Day] #

index :: (Day, Day) -> Day -> Int #

unsafeIndex :: (Day, Day) -> Day -> Int

inRange :: (Day, Day) -> Day -> Bool #

rangeSize :: (Day, Day) -> Int #

unsafeRangeSize :: (Day, Day) -> Int

NFData Day 

Methods

rnf :: Day -> () #

ParseTime Day 

Methods

buildTime :: TimeLocale -> [(Char, String)] -> Maybe Day #

HasDate Day # 

Methods

date :: Lens Day Day #

data TimeOfDay :: * #

Time of day as represented in hour, minute and second (with picoseconds), typically used to express local time of day.

Instances

Eq TimeOfDay 
Data TimeOfDay 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TimeOfDay -> c TimeOfDay #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TimeOfDay #

toConstr :: TimeOfDay -> Constr #

dataTypeOf :: TimeOfDay -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c TimeOfDay) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TimeOfDay) #

gmapT :: (forall b. Data b => b -> b) -> TimeOfDay -> TimeOfDay #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TimeOfDay -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TimeOfDay -> r #

gmapQ :: (forall d. Data d => d -> u) -> TimeOfDay -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> TimeOfDay -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> TimeOfDay -> m TimeOfDay #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TimeOfDay -> m TimeOfDay #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TimeOfDay -> m TimeOfDay #

Ord TimeOfDay 
Show TimeOfDay 
NFData TimeOfDay 

Methods

rnf :: TimeOfDay -> () #

ParseTime TimeOfDay 
HasTime TimeOfDay # 

data LocalTime :: * #

A simple day and time aggregate, where the day is of the specified parameter, and the time is a TimeOfDay. Conversion of this (as local civil time) to UTC depends on the time zone. Conversion of this (as local mean time) to UT1 depends on the longitude.

Instances

Eq LocalTime 
Data LocalTime 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> LocalTime -> c LocalTime #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c LocalTime #

toConstr :: LocalTime -> Constr #

dataTypeOf :: LocalTime -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c LocalTime) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c LocalTime) #

gmapT :: (forall b. Data b => b -> b) -> LocalTime -> LocalTime #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> LocalTime -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> LocalTime -> r #

gmapQ :: (forall d. Data d => d -> u) -> LocalTime -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> LocalTime -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> LocalTime -> m LocalTime #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> LocalTime -> m LocalTime #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> LocalTime -> m LocalTime #

Ord LocalTime 
Show LocalTime 
NFData LocalTime 

Methods

rnf :: LocalTime -> () #

ParseTime LocalTime 
HasDate LocalTime # 

Methods

date :: Lens LocalTime Day #

HasTime LocalTime # 

data ZonedTime :: * #

A local time together with a TimeZone.

Instances

Data ZonedTime 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ZonedTime -> c ZonedTime #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ZonedTime #

toConstr :: ZonedTime -> Constr #

dataTypeOf :: ZonedTime -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c ZonedTime) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ZonedTime) #

gmapT :: (forall b. Data b => b -> b) -> ZonedTime -> ZonedTime #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ZonedTime -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ZonedTime -> r #

gmapQ :: (forall d. Data d => d -> u) -> ZonedTime -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> ZonedTime -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> ZonedTime -> m ZonedTime #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ZonedTime -> m ZonedTime #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ZonedTime -> m ZonedTime #

Show ZonedTime 
NFData ZonedTime 

Methods

rnf :: ZonedTime -> () #

ParseTime ZonedTime 
HasTimeZone ZonedTime # 
HasDate ZonedTime # 

Methods

date :: Lens ZonedTime Day #

HasTime ZonedTime # 

Re-exports from Data.Lens.Light

data Lens a b :: * -> * -> * #

Simple lens data type

Instances

Category * Lens 

Methods

id :: cat a a #

(.) :: cat b c -> cat a b -> cat a c #

getL :: Lens a b -> a -> b #

Get the getter function from a lens

modL :: Lens a b -> (b -> b) -> a -> a #

Get the modifier function from a lens

setL :: Lens a b -> b -> a -> a #

Get the setter function from a lens