| Copyright | (c) Eitan Chatav 2019 |
|---|---|
| Maintainer | eitan@morphism.tech |
| Stability | experimental |
| Safe Haskell | None |
| Language | Haskell2010 |
Squeal.PostgreSQL.Expression.Time
Description
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 :: '[null PGint4, null PGint4, null PGint4] ---> null PGdate
- makeTime :: '[null PGint4, null PGint4, null PGfloat8] ---> null PGtime
- makeTimestamp :: '[null PGint4, null PGint4, null PGint4, null PGint4, null PGint4, null PGfloat8] ---> null PGtimestamp
- makeTimestamptz :: '[null PGint4, null PGint4, null PGint4, null PGint4, null PGint4, null PGfloat8] ---> null PGtimestamptz
- interval_ :: Milli -> TimeUnit -> Expr (null PGinterval)
- data TimeUnit
Time Operation
class TimeOp time diff | time -> diff where Source #
Affine space operations on time types.
Minimal complete definition
Nothing
Methods
(!+) :: Operator (null time) (null diff) (null time) infixl 6 Source #
>>>printSQL (makeDate (1984 :* 7 *: 3) !+ 365)(make_date((1984 :: int4), (7 :: int4), (3 :: int4)) + (365 :: int4))
(+!) :: Operator (null diff) (null time) (null time) infixl 6 Source #
>>>printSQL (365 +! makeDate (1984 :* 7 *: 3))((365 :: int4) + make_date((1984 :: int4), (7 :: int4), (3 :: int4)))
(!-) :: Operator (null time) (null diff) (null time) infixl 6 Source #
>>>printSQL (makeDate (1984 :* 7 *: 3) !- 365)(make_date((1984 :: int4), (7 :: int4), (3 :: int4)) - (365 :: int4))
(!-!) :: Operator (null time) (null time) (null diff) infixl 6 Source #
>>>printSQL (makeDate (1984 :* 7 *: 3) !-! currentDate)(make_date((1984 :: int4), (7 :: int4), (3 :: int4)) - CURRENT_DATE)
Instances
Time Function
currentDate :: Expr (null PGdate) Source #
>>>printSQL currentDateCURRENT_DATE
currentTime :: Expr (null PGtimetz) Source #
>>>printSQL currentTimeCURRENT_TIME
currentTimestamp :: Expr (null PGtimestamptz) Source #
>>>printSQL currentTimestampCURRENT_TIMESTAMP
localTimestamp :: Expr (null PGtimestamp) Source #
>>>printSQL localTimestampLOCALTIMESTAMP
now :: Expr (null PGtimestamptz) Source #
Current date and time (equivalent to currentTimestamp)
>>>printSQL nownow()
makeDate :: '[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 :: int4), (7 :: int4), (3 :: int4))
makeTime :: '[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 :: int4), (15 :: int4), (23.5 :: float8))
makeTimestamp :: '[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 :: int4), (7 :: int4), (15 :: int4), (8 :: int4), (15 :: int4), (23.5 :: float8))
makeTimestamptz :: '[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 :: int4), (7 :: int4), (15 :: int4), (8 :: int4), (15 :: int4), (23.5 :: float8))
Interval
interval_ :: Milli -> TimeUnit -> Expr (null PGinterval) Source #
>>>printSQL $ interval_ 7 Days(INTERVAL '7.000 days')
Constructors
| Years | |
| Months | |
| Weeks | |
| Days | |
| Hours | |
| Minutes | |
| Seconds | |
| Microseconds | |
| Milliseconds | |
| Decades | |
| Centuries | |
| Millennia |