packages feed

duckdb-simple-1.0.0.0: src/Database/DuckDB/Simple/Time.hs

{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE StrictData #-}

-- |
-- Module      : Database.DuckDB.Simple.Time
-- Description : Dates and timestamps that can represent DuckDB's infinities.
module Database.DuckDB.Simple.Time (
  Unbounded (..),
  Date,
  LocalTimestamp,
  UTCTimestamp,
) where

import Data.Time (Day, LocalTime, UTCTime)

-- | A finite value or either infinity, as in @postgresql-simple@.
data Unbounded a
  = NegInfinity
  | Finite a
  | PosInfinity
  deriving (Eq, Ord, Show, Read, Functor)

-- | A DuckDB DATE, including infinity.
type Date = Unbounded Day

-- | A timestamp without a time zone, including infinity.
type LocalTimestamp = Unbounded LocalTime

-- | A timestamp with a time zone, including infinity.
type UTCTimestamp = Unbounded UTCTime