utc-0.1.0.1: A pragmatic time and date library.

Safe HaskellSafe
LanguageHaskell98

Data.UTC.Class.IsTime

Synopsis

Documentation

class IsTime t where Source

This class captures the concept of a 24-hour clock time during a day.

Methods

hour :: t -> Integer Source

Returns values in the range 0 to 23.

minute :: t -> Integer Source

Returns values in the range 0 to 59.

second :: t -> Integer Source

Returns values in the range 0 to 59.

secondFraction :: t -> Rational Source

Returns values in the range 0.0 <= x < 1.0.

setHour :: Monad m => Integer -> t -> m t Source

Accepts values in the range 0 to 23.

The function fails if the result cannot be represented by the type (cannot happen for Time and DateTime).

setMinute :: Monad m => Integer -> t -> m t Source

Accepts values in the range 0 to 59.

The function fails if the result cannot be represented by the type (cannot happen for Time and DateTime).

setSecond :: Monad m => Integer -> t -> m t Source

Accepts values in the range 0 to 59.

The function fails if the result cannot be represented by the type (cannot happen for Time and DateTime).

setSecondFraction :: Monad m => Rational -> t -> m t Source

Accepts values in the range 0.0 <= x < 1.0.

The function fails if the result cannot be represented by the type (cannot happen for Time and DateTime).

addHours :: Monad m => Integer -> t -> m t Source

Adds an arbitrary count of hours (positive or negative).

  • Full days flow over to addDays if the type is also an instance of IsDate (this is the case for DateTime).
  • Types not implementing the IsDate class should just ignore the days part on overflow (like Time does).
  • Fails if the result cannot be represented by the type (cannot happen for Time and DateTime).

addMinutes :: Monad m => Integer -> t -> m t Source

Adds an arbitrary count of minutes (positive or negative).

  • Full hours flow over to addHours.
  • Fails if the result cannot be represented by the type (cannot happen for Time and DateTime).

addSeconds :: Monad m => Integer -> t -> m t Source

Adds an arbitrary count of seconds (positive or negative).

  • Full minutes flow over to addMinutes.
  • Fails if the result cannot be represented by the type (cannot happen for Time and DateTime).

addSecondFractions :: Monad m => Rational -> t -> m t Source

Adds an arbitrary second fraction (positive or negative).

  • Full seconds flow over to addSeconds.
  • Instances of this class are not required to preserve full precision (although Time and DateTime do so).
  • Fails if the result cannot be represented by the type (cannot happen for Time and DateTime).