Copyright | (c) Eitan Chatav 2019 |
---|---|
Maintainer | eitan@morphism.tech |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Date/Time functions and operators
Synopsis
- class TimeOp time diff | time -> diff where
- currentDate :: Expr (null PGdate)
- currentTime :: Expr (null PGtimetz)
- currentTimestamp :: Expr (null PGtimestamptz)
- localTime :: Expr (null PGtime)
- localTimestamp :: Expr (null PGtimestamp)
- now :: Expr (null PGtimestamptz)
- makeDate :: FunctionN '[null PGint4, null PGint4, null PGint4] (null PGdate)
- makeTime :: FunctionN '[null PGint4, null PGint4, null PGfloat8] (null PGtime)
- makeTimestamp :: FunctionN '[null PGint4, null PGint4, null PGint4, null PGint4, null PGint4, null PGfloat8] (null PGtimestamp)
- makeTimestamptz :: FunctionN '[null PGint4, null PGint4, null PGint4, null PGint4, null PGint4, null PGfloat8] (null PGtimestamptz)
- interval_ :: Double -> TimeUnit -> Expr (null PGinterval)
- data TimeUnit
Documentation
class TimeOp time diff | time -> diff where Source #
Affine space operations on time types.
Nothing
(!+) :: Operator (null time) (null diff) (null time) infixl 6 Source #
>>>
printSQL (makeDate (1984 :* 7 *: 3) !+ 365)
(make_date(1984, 7, 3) + 365)
(+!) :: Operator (null diff) (null time) (null time) infixl 6 Source #
>>>
printSQL (365 +! makeDate (1984 :* 7 *: 3))
(365 + make_date(1984, 7, 3))
(!-) :: Operator (null time) (null diff) (null time) infixl 6 Source #
>>>
printSQL (makeDate (1984 :* 7 *: 3) !- 365)
(make_date(1984, 7, 3) - 365)
(!-!) :: Operator (null time) (null time) (null diff) infixl 6 Source #
>>>
printSQL (makeDate (1984 :* 7 *: 3) !-! currentDate)
(make_date(1984, 7, 3) - CURRENT_DATE)
Instances
currentDate :: Expr (null PGdate) Source #
>>>
printSQL currentDate
CURRENT_DATE
currentTime :: Expr (null PGtimetz) Source #
>>>
printSQL currentTime
CURRENT_TIME
currentTimestamp :: Expr (null PGtimestamptz) Source #
>>>
printSQL currentTimestamp
CURRENT_TIMESTAMP
localTimestamp :: Expr (null PGtimestamp) Source #
>>>
printSQL localTimestamp
LOCALTIMESTAMP
now :: Expr (null PGtimestamptz) Source #
Current date and time (equivalent to currentTimestamp
)
>>>
printSQL now
now()
makeDate :: FunctionN '[null PGint4, null PGint4, null PGint4] (null PGdate) Source #
Create date from year, month and day fields
>>>
printSQL (makeDate (1984 :* 7 *: 3))
make_date(1984, 7, 3)
makeTime :: FunctionN '[null PGint4, null PGint4, null PGfloat8] (null PGtime) Source #
Create time from hour, minute and seconds fields
>>>
printSQL (makeTime (8 :* 15 *: 23.5))
make_time(8, 15, 23.5)
makeTimestamp :: FunctionN '[null PGint4, null PGint4, null PGint4, null PGint4, null PGint4, null PGfloat8] (null PGtimestamp) Source #
Create timestamp from year, month, day, hour, minute and seconds fields
>>>
printSQL (makeTimestamp (2013 :* 7 :* 15 :* 8 :* 15 *: 23.5))
make_timestamp(2013, 7, 15, 8, 15, 23.5)
makeTimestamptz :: FunctionN '[null PGint4, null PGint4, null PGint4, null PGint4, null PGint4, null PGfloat8] (null PGtimestamptz) Source #
Create timestamp with time zone from year, month, day, hour, minute and seconds fields; the current time zone is used
>>>
printSQL (makeTimestamptz (2013 :* 7 :* 15 :* 8 :* 15 *: 23.5))
make_timestamptz(2013, 7, 15, 8, 15, 23.5)
interval_ :: Double -> TimeUnit -> Expr (null PGinterval) Source #
>>>
printSQL $ interval_ 7 Days
(INTERVAL '7.0 days')