module ClickHaskell.Primitive.TDateTime where
import ClickHaskell.Primitive.Serialization
import Control.DeepSeq (NFData)
import Data.Bits (Bits)
import Data.ByteString.Builder (byteString, word32LE, word64LE)
import Data.ByteString.Char8 as BS8 (length, pack, replicate)
import Data.Coerce (coerce)
import Data.Proxy (Proxy (..))
import Data.Time (UTCTime)
import Data.Time.Clock.POSIX (posixSecondsToUTCTime, utcTimeToPOSIXSeconds)
import Data.Word (Word32, Word64)
import GHC.TypeLits (KnownNat, KnownSymbol, Nat, Symbol, natVal, symbolVal)
import Data.Binary.Get (getWord32le, getWord64le)
newtype DateTime (tz :: Symbol) = MkDateTime Word32
deriving newtype (Int -> DateTime tz -> ShowS
[DateTime tz] -> ShowS
DateTime tz -> String
(Int -> DateTime tz -> ShowS)
-> (DateTime tz -> String)
-> ([DateTime tz] -> ShowS)
-> Show (DateTime tz)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall (tz :: Symbol). Int -> DateTime tz -> ShowS
forall (tz :: Symbol). [DateTime tz] -> ShowS
forall (tz :: Symbol). DateTime tz -> String
$cshowsPrec :: forall (tz :: Symbol). Int -> DateTime tz -> ShowS
showsPrec :: Int -> DateTime tz -> ShowS
$cshow :: forall (tz :: Symbol). DateTime tz -> String
show :: DateTime tz -> String
$cshowList :: forall (tz :: Symbol). [DateTime tz] -> ShowS
showList :: [DateTime tz] -> ShowS
Show, DateTime tz -> DateTime tz -> Bool
(DateTime tz -> DateTime tz -> Bool)
-> (DateTime tz -> DateTime tz -> Bool) -> Eq (DateTime tz)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall (tz :: Symbol). DateTime tz -> DateTime tz -> Bool
$c== :: forall (tz :: Symbol). DateTime tz -> DateTime tz -> Bool
== :: DateTime tz -> DateTime tz -> Bool
$c/= :: forall (tz :: Symbol). DateTime tz -> DateTime tz -> Bool
/= :: DateTime tz -> DateTime tz -> Bool
Eq, Integer -> DateTime tz
DateTime tz -> DateTime tz
DateTime tz -> DateTime tz -> DateTime tz
(DateTime tz -> DateTime tz -> DateTime tz)
-> (DateTime tz -> DateTime tz -> DateTime tz)
-> (DateTime tz -> DateTime tz -> DateTime tz)
-> (DateTime tz -> DateTime tz)
-> (DateTime tz -> DateTime tz)
-> (DateTime tz -> DateTime tz)
-> (Integer -> DateTime tz)
-> Num (DateTime tz)
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
forall (tz :: Symbol). Integer -> DateTime tz
forall (tz :: Symbol). DateTime tz -> DateTime tz
forall (tz :: Symbol). DateTime tz -> DateTime tz -> DateTime tz
$c+ :: forall (tz :: Symbol). DateTime tz -> DateTime tz -> DateTime tz
+ :: DateTime tz -> DateTime tz -> DateTime tz
$c- :: forall (tz :: Symbol). DateTime tz -> DateTime tz -> DateTime tz
- :: DateTime tz -> DateTime tz -> DateTime tz
$c* :: forall (tz :: Symbol). DateTime tz -> DateTime tz -> DateTime tz
* :: DateTime tz -> DateTime tz -> DateTime tz
$cnegate :: forall (tz :: Symbol). DateTime tz -> DateTime tz
negate :: DateTime tz -> DateTime tz
$cabs :: forall (tz :: Symbol). DateTime tz -> DateTime tz
abs :: DateTime tz -> DateTime tz
$csignum :: forall (tz :: Symbol). DateTime tz -> DateTime tz
signum :: DateTime tz -> DateTime tz
$cfromInteger :: forall (tz :: Symbol). Integer -> DateTime tz
fromInteger :: Integer -> DateTime tz
Num, Eq (DateTime tz)
DateTime tz
Eq (DateTime tz) =>
(DateTime tz -> DateTime tz -> DateTime tz)
-> (DateTime tz -> DateTime tz -> DateTime tz)
-> (DateTime tz -> DateTime tz -> DateTime tz)
-> (DateTime tz -> DateTime tz)
-> (DateTime tz -> Int -> DateTime tz)
-> (DateTime tz -> Int -> DateTime tz)
-> DateTime tz
-> (Int -> DateTime tz)
-> (DateTime tz -> Int -> DateTime tz)
-> (DateTime tz -> Int -> DateTime tz)
-> (DateTime tz -> Int -> DateTime tz)
-> (DateTime tz -> Int -> Bool)
-> (DateTime tz -> Maybe Int)
-> (DateTime tz -> Int)
-> (DateTime tz -> Bool)
-> (DateTime tz -> Int -> DateTime tz)
-> (DateTime tz -> Int -> DateTime tz)
-> (DateTime tz -> Int -> DateTime tz)
-> (DateTime tz -> Int -> DateTime tz)
-> (DateTime tz -> Int -> DateTime tz)
-> (DateTime tz -> Int -> DateTime tz)
-> (DateTime tz -> Int)
-> Bits (DateTime tz)
Int -> DateTime tz
DateTime tz -> Bool
DateTime tz -> Int
DateTime tz -> Maybe Int
DateTime tz -> DateTime tz
DateTime tz -> Int -> Bool
DateTime tz -> Int -> DateTime tz
DateTime tz -> DateTime tz -> DateTime tz
forall a.
Eq a =>
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> a
-> (Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> Bool)
-> (a -> Maybe Int)
-> (a -> Int)
-> (a -> Bool)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int)
-> Bits a
forall (tz :: Symbol). Eq (DateTime tz)
forall (tz :: Symbol). DateTime tz
forall (tz :: Symbol). Int -> DateTime tz
forall (tz :: Symbol). DateTime tz -> Bool
forall (tz :: Symbol). DateTime tz -> Int
forall (tz :: Symbol). DateTime tz -> Maybe Int
forall (tz :: Symbol). DateTime tz -> DateTime tz
forall (tz :: Symbol). DateTime tz -> Int -> Bool
forall (tz :: Symbol). DateTime tz -> Int -> DateTime tz
forall (tz :: Symbol). DateTime tz -> DateTime tz -> DateTime tz
$c.&. :: forall (tz :: Symbol). DateTime tz -> DateTime tz -> DateTime tz
.&. :: DateTime tz -> DateTime tz -> DateTime tz
$c.|. :: forall (tz :: Symbol). DateTime tz -> DateTime tz -> DateTime tz
.|. :: DateTime tz -> DateTime tz -> DateTime tz
$cxor :: forall (tz :: Symbol). DateTime tz -> DateTime tz -> DateTime tz
xor :: DateTime tz -> DateTime tz -> DateTime tz
$ccomplement :: forall (tz :: Symbol). DateTime tz -> DateTime tz
complement :: DateTime tz -> DateTime tz
$cshift :: forall (tz :: Symbol). DateTime tz -> Int -> DateTime tz
shift :: DateTime tz -> Int -> DateTime tz
$crotate :: forall (tz :: Symbol). DateTime tz -> Int -> DateTime tz
rotate :: DateTime tz -> Int -> DateTime tz
$czeroBits :: forall (tz :: Symbol). DateTime tz
zeroBits :: DateTime tz
$cbit :: forall (tz :: Symbol). Int -> DateTime tz
bit :: Int -> DateTime tz
$csetBit :: forall (tz :: Symbol). DateTime tz -> Int -> DateTime tz
setBit :: DateTime tz -> Int -> DateTime tz
$cclearBit :: forall (tz :: Symbol). DateTime tz -> Int -> DateTime tz
clearBit :: DateTime tz -> Int -> DateTime tz
$ccomplementBit :: forall (tz :: Symbol). DateTime tz -> Int -> DateTime tz
complementBit :: DateTime tz -> Int -> DateTime tz
$ctestBit :: forall (tz :: Symbol). DateTime tz -> Int -> Bool
testBit :: DateTime tz -> Int -> Bool
$cbitSizeMaybe :: forall (tz :: Symbol). DateTime tz -> Maybe Int
bitSizeMaybe :: DateTime tz -> Maybe Int
$cbitSize :: forall (tz :: Symbol). DateTime tz -> Int
bitSize :: DateTime tz -> Int
$cisSigned :: forall (tz :: Symbol). DateTime tz -> Bool
isSigned :: DateTime tz -> Bool
$cshiftL :: forall (tz :: Symbol). DateTime tz -> Int -> DateTime tz
shiftL :: DateTime tz -> Int -> DateTime tz
$cunsafeShiftL :: forall (tz :: Symbol). DateTime tz -> Int -> DateTime tz
unsafeShiftL :: DateTime tz -> Int -> DateTime tz
$cshiftR :: forall (tz :: Symbol). DateTime tz -> Int -> DateTime tz
shiftR :: DateTime tz -> Int -> DateTime tz
$cunsafeShiftR :: forall (tz :: Symbol). DateTime tz -> Int -> DateTime tz
unsafeShiftR :: DateTime tz -> Int -> DateTime tz
$crotateL :: forall (tz :: Symbol). DateTime tz -> Int -> DateTime tz
rotateL :: DateTime tz -> Int -> DateTime tz
$crotateR :: forall (tz :: Symbol). DateTime tz -> Int -> DateTime tz
rotateR :: DateTime tz -> Int -> DateTime tz
$cpopCount :: forall (tz :: Symbol). DateTime tz -> Int
popCount :: DateTime tz -> Int
Bits, Int -> DateTime tz
DateTime tz -> Int
DateTime tz -> [DateTime tz]
DateTime tz -> DateTime tz
DateTime tz -> DateTime tz -> [DateTime tz]
DateTime tz -> DateTime tz -> DateTime tz -> [DateTime tz]
(DateTime tz -> DateTime tz)
-> (DateTime tz -> DateTime tz)
-> (Int -> DateTime tz)
-> (DateTime tz -> Int)
-> (DateTime tz -> [DateTime tz])
-> (DateTime tz -> DateTime tz -> [DateTime tz])
-> (DateTime tz -> DateTime tz -> [DateTime tz])
-> (DateTime tz -> DateTime tz -> DateTime tz -> [DateTime tz])
-> Enum (DateTime tz)
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
forall (tz :: Symbol). Int -> DateTime tz
forall (tz :: Symbol). DateTime tz -> Int
forall (tz :: Symbol). DateTime tz -> [DateTime tz]
forall (tz :: Symbol). DateTime tz -> DateTime tz
forall (tz :: Symbol). DateTime tz -> DateTime tz -> [DateTime tz]
forall (tz :: Symbol).
DateTime tz -> DateTime tz -> DateTime tz -> [DateTime tz]
$csucc :: forall (tz :: Symbol). DateTime tz -> DateTime tz
succ :: DateTime tz -> DateTime tz
$cpred :: forall (tz :: Symbol). DateTime tz -> DateTime tz
pred :: DateTime tz -> DateTime tz
$ctoEnum :: forall (tz :: Symbol). Int -> DateTime tz
toEnum :: Int -> DateTime tz
$cfromEnum :: forall (tz :: Symbol). DateTime tz -> Int
fromEnum :: DateTime tz -> Int
$cenumFrom :: forall (tz :: Symbol). DateTime tz -> [DateTime tz]
enumFrom :: DateTime tz -> [DateTime tz]
$cenumFromThen :: forall (tz :: Symbol). DateTime tz -> DateTime tz -> [DateTime tz]
enumFromThen :: DateTime tz -> DateTime tz -> [DateTime tz]
$cenumFromTo :: forall (tz :: Symbol). DateTime tz -> DateTime tz -> [DateTime tz]
enumFromTo :: DateTime tz -> DateTime tz -> [DateTime tz]
$cenumFromThenTo :: forall (tz :: Symbol).
DateTime tz -> DateTime tz -> DateTime tz -> [DateTime tz]
enumFromThenTo :: DateTime tz -> DateTime tz -> DateTime tz -> [DateTime tz]
Enum, Eq (DateTime tz)
Eq (DateTime tz) =>
(DateTime tz -> DateTime tz -> Ordering)
-> (DateTime tz -> DateTime tz -> Bool)
-> (DateTime tz -> DateTime tz -> Bool)
-> (DateTime tz -> DateTime tz -> Bool)
-> (DateTime tz -> DateTime tz -> Bool)
-> (DateTime tz -> DateTime tz -> DateTime tz)
-> (DateTime tz -> DateTime tz -> DateTime tz)
-> Ord (DateTime tz)
DateTime tz -> DateTime tz -> Bool
DateTime tz -> DateTime tz -> Ordering
DateTime tz -> DateTime tz -> DateTime tz
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall (tz :: Symbol). Eq (DateTime tz)
forall (tz :: Symbol). DateTime tz -> DateTime tz -> Bool
forall (tz :: Symbol). DateTime tz -> DateTime tz -> Ordering
forall (tz :: Symbol). DateTime tz -> DateTime tz -> DateTime tz
$ccompare :: forall (tz :: Symbol). DateTime tz -> DateTime tz -> Ordering
compare :: DateTime tz -> DateTime tz -> Ordering
$c< :: forall (tz :: Symbol). DateTime tz -> DateTime tz -> Bool
< :: DateTime tz -> DateTime tz -> Bool
$c<= :: forall (tz :: Symbol). DateTime tz -> DateTime tz -> Bool
<= :: DateTime tz -> DateTime tz -> Bool
$c> :: forall (tz :: Symbol). DateTime tz -> DateTime tz -> Bool
> :: DateTime tz -> DateTime tz -> Bool
$c>= :: forall (tz :: Symbol). DateTime tz -> DateTime tz -> Bool
>= :: DateTime tz -> DateTime tz -> Bool
$cmax :: forall (tz :: Symbol). DateTime tz -> DateTime tz -> DateTime tz
max :: DateTime tz -> DateTime tz -> DateTime tz
$cmin :: forall (tz :: Symbol). DateTime tz -> DateTime tz -> DateTime tz
min :: DateTime tz -> DateTime tz -> DateTime tz
Ord, Num (DateTime tz)
Ord (DateTime tz)
(Num (DateTime tz), Ord (DateTime tz)) =>
(DateTime tz -> Rational) -> Real (DateTime tz)
DateTime tz -> Rational
forall a. (Num a, Ord a) => (a -> Rational) -> Real a
forall (tz :: Symbol). Num (DateTime tz)
forall (tz :: Symbol). Ord (DateTime tz)
forall (tz :: Symbol). DateTime tz -> Rational
$ctoRational :: forall (tz :: Symbol). DateTime tz -> Rational
toRational :: DateTime tz -> Rational
Real, Enum (DateTime tz)
Real (DateTime tz)
(Real (DateTime tz), Enum (DateTime tz)) =>
(DateTime tz -> DateTime tz -> DateTime tz)
-> (DateTime tz -> DateTime tz -> DateTime tz)
-> (DateTime tz -> DateTime tz -> DateTime tz)
-> (DateTime tz -> DateTime tz -> DateTime tz)
-> (DateTime tz -> DateTime tz -> (DateTime tz, DateTime tz))
-> (DateTime tz -> DateTime tz -> (DateTime tz, DateTime tz))
-> (DateTime tz -> Integer)
-> Integral (DateTime tz)
DateTime tz -> Integer
DateTime tz -> DateTime tz -> (DateTime tz, DateTime tz)
DateTime tz -> DateTime tz -> DateTime tz
forall a.
(Real a, Enum a) =>
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> (a, a))
-> (a -> a -> (a, a))
-> (a -> Integer)
-> Integral a
forall (tz :: Symbol). Enum (DateTime tz)
forall (tz :: Symbol). Real (DateTime tz)
forall (tz :: Symbol). DateTime tz -> Integer
forall (tz :: Symbol).
DateTime tz -> DateTime tz -> (DateTime tz, DateTime tz)
forall (tz :: Symbol). DateTime tz -> DateTime tz -> DateTime tz
$cquot :: forall (tz :: Symbol). DateTime tz -> DateTime tz -> DateTime tz
quot :: DateTime tz -> DateTime tz -> DateTime tz
$crem :: forall (tz :: Symbol). DateTime tz -> DateTime tz -> DateTime tz
rem :: DateTime tz -> DateTime tz -> DateTime tz
$cdiv :: forall (tz :: Symbol). DateTime tz -> DateTime tz -> DateTime tz
div :: DateTime tz -> DateTime tz -> DateTime tz
$cmod :: forall (tz :: Symbol). DateTime tz -> DateTime tz -> DateTime tz
mod :: DateTime tz -> DateTime tz -> DateTime tz
$cquotRem :: forall (tz :: Symbol).
DateTime tz -> DateTime tz -> (DateTime tz, DateTime tz)
quotRem :: DateTime tz -> DateTime tz -> (DateTime tz, DateTime tz)
$cdivMod :: forall (tz :: Symbol).
DateTime tz -> DateTime tz -> (DateTime tz, DateTime tz)
divMod :: DateTime tz -> DateTime tz -> (DateTime tz, DateTime tz)
$ctoInteger :: forall (tz :: Symbol). DateTime tz -> Integer
toInteger :: DateTime tz -> Integer
Integral, DateTime tz
DateTime tz -> DateTime tz -> Bounded (DateTime tz)
forall a. a -> a -> Bounded a
forall (tz :: Symbol). DateTime tz
$cminBound :: forall (tz :: Symbol). DateTime tz
minBound :: DateTime tz
$cmaxBound :: forall (tz :: Symbol). DateTime tz
maxBound :: DateTime tz
Bounded, DateTime tz -> ()
(DateTime tz -> ()) -> NFData (DateTime tz)
forall a. (a -> ()) -> NFData a
forall (tz :: Symbol). DateTime tz -> ()
$crnf :: forall (tz :: Symbol). DateTime tz -> ()
rnf :: DateTime tz -> ()
NFData)
instance KnownSymbol tz => IsChType (DateTime tz)
where
chTypeName :: String
chTypeName = case forall (n :: Symbol) (proxy :: Symbol -> *).
KnownSymbol n =>
proxy n -> String
symbolVal @tz Proxy tz
forall {k} (t :: k). Proxy t
Proxy of
String
"" -> String
"DateTime"
String
tz -> String
"DateTime('" String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
tz String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
"')"
defaultValueOfTypeName :: DateTime tz
defaultValueOfTypeName = Word32 -> DateTime tz
forall (tz :: Symbol). Word32 -> DateTime tz
MkDateTime Word32
0
instance Serializable (DateTime tz) where
serialize :: ProtocolRevision -> DateTime tz -> Builder
serialize ProtocolRevision
_ (MkDateTime Word32
w32) = Word32 -> Builder
word32LE Word32
w32
deserialize :: ProtocolRevision -> Get (DateTime tz)
deserialize ProtocolRevision
_ = Word32 -> DateTime tz
forall (tz :: Symbol). Word32 -> DateTime tz
MkDateTime (Word32 -> DateTime tz) -> Get Word32 -> Get (DateTime tz)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Word32
getWord32le
{-# INLINE deserialize #-}
instance ToChType (DateTime tz) Word32 where
toChType :: Word32 -> DateTime tz
toChType = Word32 -> DateTime tz
forall (tz :: Symbol). Word32 -> DateTime tz
MkDateTime
fromChType :: DateTime tz -> Word32
fromChType (MkDateTime Word32
w32)= Word32
w32
instance ToChType (DateTime tz) UTCTime where
toChType :: UTCTime -> DateTime tz
toChType = Word32 -> DateTime tz
forall (tz :: Symbol). Word32 -> DateTime tz
MkDateTime (Word32 -> DateTime tz)
-> (UTCTime -> Word32) -> UTCTime -> DateTime tz
forall b c a. (b -> c) -> (a -> b) -> a -> c
. POSIXTime -> Word32
forall b. Integral b => POSIXTime -> b
forall a b. (RealFrac a, Integral b) => a -> b
floor (POSIXTime -> Word32)
-> (UTCTime -> POSIXTime) -> UTCTime -> Word32
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UTCTime -> POSIXTime
utcTimeToPOSIXSeconds
fromChType :: DateTime tz -> UTCTime
fromChType (MkDateTime Word32
w32) = POSIXTime -> UTCTime
posixSecondsToUTCTime (Word32 -> POSIXTime
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
w32)
instance ToQueryPart (DateTime tz)
where
toQueryPart :: DateTime tz -> Builder
toQueryPart DateTime tz
chDateTime = let time :: StrictByteString
time = String -> StrictByteString
BS8.pack (String -> StrictByteString)
-> (DateTime tz -> String) -> DateTime tz -> StrictByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word32 -> String
forall a. Show a => a -> String
show (Word32 -> String)
-> (DateTime tz -> Word32) -> DateTime tz -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. Coercible a b => a -> b
forall a b. Coercible a b => a -> b
coerce @(DateTime tz) @Word32 (DateTime tz -> StrictByteString)
-> DateTime tz -> StrictByteString
forall a b. (a -> b) -> a -> b
$ DateTime tz
chDateTime
in StrictByteString -> Builder
byteString (Int -> Char -> StrictByteString
BS8.replicate (Int
10 Int -> Int -> Int
forall a. Num a => a -> a -> a
- StrictByteString -> Int
BS8.length StrictByteString
time) Char
'0' StrictByteString -> StrictByteString -> StrictByteString
forall a. Semigroup a => a -> a -> a
<> StrictByteString
time)
newtype DateTime64 (precision :: Nat) (tz :: Symbol) = MkDateTime64 Word64
deriving newtype (Int -> DateTime64 precision tz -> ShowS
[DateTime64 precision tz] -> ShowS
DateTime64 precision tz -> String
(Int -> DateTime64 precision tz -> ShowS)
-> (DateTime64 precision tz -> String)
-> ([DateTime64 precision tz] -> ShowS)
-> Show (DateTime64 precision tz)
forall (precision :: Nat) (tz :: Symbol).
Int -> DateTime64 precision tz -> ShowS
forall (precision :: Nat) (tz :: Symbol).
[DateTime64 precision tz] -> ShowS
forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall (precision :: Nat) (tz :: Symbol).
Int -> DateTime64 precision tz -> ShowS
showsPrec :: Int -> DateTime64 precision tz -> ShowS
$cshow :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> String
show :: DateTime64 precision tz -> String
$cshowList :: forall (precision :: Nat) (tz :: Symbol).
[DateTime64 precision tz] -> ShowS
showList :: [DateTime64 precision tz] -> ShowS
Show, DateTime64 precision tz -> DateTime64 precision tz -> Bool
(DateTime64 precision tz -> DateTime64 precision tz -> Bool)
-> (DateTime64 precision tz -> DateTime64 precision tz -> Bool)
-> Eq (DateTime64 precision tz)
forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> DateTime64 precision tz -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> DateTime64 precision tz -> Bool
== :: DateTime64 precision tz -> DateTime64 precision tz -> Bool
$c/= :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> DateTime64 precision tz -> Bool
/= :: DateTime64 precision tz -> DateTime64 precision tz -> Bool
Eq, Integer -> DateTime64 precision tz
DateTime64 precision tz -> DateTime64 precision tz
DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz
(DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz)
-> (DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz)
-> (DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz)
-> (DateTime64 precision tz -> DateTime64 precision tz)
-> (DateTime64 precision tz -> DateTime64 precision tz)
-> (DateTime64 precision tz -> DateTime64 precision tz)
-> (Integer -> DateTime64 precision tz)
-> Num (DateTime64 precision tz)
forall (precision :: Nat) (tz :: Symbol).
Integer -> DateTime64 precision tz
forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> DateTime64 precision tz
forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
$c+ :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz
+ :: DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz
$c- :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz
- :: DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz
$c* :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz
* :: DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz
$cnegate :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> DateTime64 precision tz
negate :: DateTime64 precision tz -> DateTime64 precision tz
$cabs :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> DateTime64 precision tz
abs :: DateTime64 precision tz -> DateTime64 precision tz
$csignum :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> DateTime64 precision tz
signum :: DateTime64 precision tz -> DateTime64 precision tz
$cfromInteger :: forall (precision :: Nat) (tz :: Symbol).
Integer -> DateTime64 precision tz
fromInteger :: Integer -> DateTime64 precision tz
Num, Eq (DateTime64 precision tz)
DateTime64 precision tz
Eq (DateTime64 precision tz) =>
(DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz)
-> (DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz)
-> (DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz)
-> (DateTime64 precision tz -> DateTime64 precision tz)
-> (DateTime64 precision tz -> Int -> DateTime64 precision tz)
-> (DateTime64 precision tz -> Int -> DateTime64 precision tz)
-> DateTime64 precision tz
-> (Int -> DateTime64 precision tz)
-> (DateTime64 precision tz -> Int -> DateTime64 precision tz)
-> (DateTime64 precision tz -> Int -> DateTime64 precision tz)
-> (DateTime64 precision tz -> Int -> DateTime64 precision tz)
-> (DateTime64 precision tz -> Int -> Bool)
-> (DateTime64 precision tz -> Maybe Int)
-> (DateTime64 precision tz -> Int)
-> (DateTime64 precision tz -> Bool)
-> (DateTime64 precision tz -> Int -> DateTime64 precision tz)
-> (DateTime64 precision tz -> Int -> DateTime64 precision tz)
-> (DateTime64 precision tz -> Int -> DateTime64 precision tz)
-> (DateTime64 precision tz -> Int -> DateTime64 precision tz)
-> (DateTime64 precision tz -> Int -> DateTime64 precision tz)
-> (DateTime64 precision tz -> Int -> DateTime64 precision tz)
-> (DateTime64 precision tz -> Int)
-> Bits (DateTime64 precision tz)
Int -> DateTime64 precision tz
DateTime64 precision tz -> Bool
DateTime64 precision tz -> Int
DateTime64 precision tz -> Maybe Int
DateTime64 precision tz -> DateTime64 precision tz
DateTime64 precision tz -> Int -> Bool
DateTime64 precision tz -> Int -> DateTime64 precision tz
DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz
forall (precision :: Nat) (tz :: Symbol).
Eq (DateTime64 precision tz)
forall (precision :: Nat) (tz :: Symbol). DateTime64 precision tz
forall (precision :: Nat) (tz :: Symbol).
Int -> DateTime64 precision tz
forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> Bool
forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> Int
forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> Maybe Int
forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> DateTime64 precision tz
forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> Int -> Bool
forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> Int -> DateTime64 precision tz
forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz
forall a.
Eq a =>
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> a
-> (Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> Bool)
-> (a -> Maybe Int)
-> (a -> Int)
-> (a -> Bool)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int)
-> Bits a
$c.&. :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz
.&. :: DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz
$c.|. :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz
.|. :: DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz
$cxor :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz
xor :: DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz
$ccomplement :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> DateTime64 precision tz
complement :: DateTime64 precision tz -> DateTime64 precision tz
$cshift :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> Int -> DateTime64 precision tz
shift :: DateTime64 precision tz -> Int -> DateTime64 precision tz
$crotate :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> Int -> DateTime64 precision tz
rotate :: DateTime64 precision tz -> Int -> DateTime64 precision tz
$czeroBits :: forall (precision :: Nat) (tz :: Symbol). DateTime64 precision tz
zeroBits :: DateTime64 precision tz
$cbit :: forall (precision :: Nat) (tz :: Symbol).
Int -> DateTime64 precision tz
bit :: Int -> DateTime64 precision tz
$csetBit :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> Int -> DateTime64 precision tz
setBit :: DateTime64 precision tz -> Int -> DateTime64 precision tz
$cclearBit :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> Int -> DateTime64 precision tz
clearBit :: DateTime64 precision tz -> Int -> DateTime64 precision tz
$ccomplementBit :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> Int -> DateTime64 precision tz
complementBit :: DateTime64 precision tz -> Int -> DateTime64 precision tz
$ctestBit :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> Int -> Bool
testBit :: DateTime64 precision tz -> Int -> Bool
$cbitSizeMaybe :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> Maybe Int
bitSizeMaybe :: DateTime64 precision tz -> Maybe Int
$cbitSize :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> Int
bitSize :: DateTime64 precision tz -> Int
$cisSigned :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> Bool
isSigned :: DateTime64 precision tz -> Bool
$cshiftL :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> Int -> DateTime64 precision tz
shiftL :: DateTime64 precision tz -> Int -> DateTime64 precision tz
$cunsafeShiftL :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> Int -> DateTime64 precision tz
unsafeShiftL :: DateTime64 precision tz -> Int -> DateTime64 precision tz
$cshiftR :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> Int -> DateTime64 precision tz
shiftR :: DateTime64 precision tz -> Int -> DateTime64 precision tz
$cunsafeShiftR :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> Int -> DateTime64 precision tz
unsafeShiftR :: DateTime64 precision tz -> Int -> DateTime64 precision tz
$crotateL :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> Int -> DateTime64 precision tz
rotateL :: DateTime64 precision tz -> Int -> DateTime64 precision tz
$crotateR :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> Int -> DateTime64 precision tz
rotateR :: DateTime64 precision tz -> Int -> DateTime64 precision tz
$cpopCount :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> Int
popCount :: DateTime64 precision tz -> Int
Bits, Int -> DateTime64 precision tz
DateTime64 precision tz -> Int
DateTime64 precision tz -> [DateTime64 precision tz]
DateTime64 precision tz -> DateTime64 precision tz
DateTime64 precision tz
-> DateTime64 precision tz -> [DateTime64 precision tz]
DateTime64 precision tz
-> DateTime64 precision tz
-> DateTime64 precision tz
-> [DateTime64 precision tz]
(DateTime64 precision tz -> DateTime64 precision tz)
-> (DateTime64 precision tz -> DateTime64 precision tz)
-> (Int -> DateTime64 precision tz)
-> (DateTime64 precision tz -> Int)
-> (DateTime64 precision tz -> [DateTime64 precision tz])
-> (DateTime64 precision tz
-> DateTime64 precision tz -> [DateTime64 precision tz])
-> (DateTime64 precision tz
-> DateTime64 precision tz -> [DateTime64 precision tz])
-> (DateTime64 precision tz
-> DateTime64 precision tz
-> DateTime64 precision tz
-> [DateTime64 precision tz])
-> Enum (DateTime64 precision tz)
forall (precision :: Nat) (tz :: Symbol).
Int -> DateTime64 precision tz
forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> Int
forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> [DateTime64 precision tz]
forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> DateTime64 precision tz
forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz
-> DateTime64 precision tz -> [DateTime64 precision tz]
forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz
-> DateTime64 precision tz
-> DateTime64 precision tz
-> [DateTime64 precision tz]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> DateTime64 precision tz
succ :: DateTime64 precision tz -> DateTime64 precision tz
$cpred :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> DateTime64 precision tz
pred :: DateTime64 precision tz -> DateTime64 precision tz
$ctoEnum :: forall (precision :: Nat) (tz :: Symbol).
Int -> DateTime64 precision tz
toEnum :: Int -> DateTime64 precision tz
$cfromEnum :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> Int
fromEnum :: DateTime64 precision tz -> Int
$cenumFrom :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> [DateTime64 precision tz]
enumFrom :: DateTime64 precision tz -> [DateTime64 precision tz]
$cenumFromThen :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz
-> DateTime64 precision tz -> [DateTime64 precision tz]
enumFromThen :: DateTime64 precision tz
-> DateTime64 precision tz -> [DateTime64 precision tz]
$cenumFromTo :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz
-> DateTime64 precision tz -> [DateTime64 precision tz]
enumFromTo :: DateTime64 precision tz
-> DateTime64 precision tz -> [DateTime64 precision tz]
$cenumFromThenTo :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz
-> DateTime64 precision tz
-> DateTime64 precision tz
-> [DateTime64 precision tz]
enumFromThenTo :: DateTime64 precision tz
-> DateTime64 precision tz
-> DateTime64 precision tz
-> [DateTime64 precision tz]
Enum, Eq (DateTime64 precision tz)
Eq (DateTime64 precision tz) =>
(DateTime64 precision tz -> DateTime64 precision tz -> Ordering)
-> (DateTime64 precision tz -> DateTime64 precision tz -> Bool)
-> (DateTime64 precision tz -> DateTime64 precision tz -> Bool)
-> (DateTime64 precision tz -> DateTime64 precision tz -> Bool)
-> (DateTime64 precision tz -> DateTime64 precision tz -> Bool)
-> (DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz)
-> (DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz)
-> Ord (DateTime64 precision tz)
DateTime64 precision tz -> DateTime64 precision tz -> Bool
DateTime64 precision tz -> DateTime64 precision tz -> Ordering
DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz
forall (precision :: Nat) (tz :: Symbol).
Eq (DateTime64 precision tz)
forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> DateTime64 precision tz -> Bool
forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> DateTime64 precision tz -> Ordering
forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> DateTime64 precision tz -> Ordering
compare :: DateTime64 precision tz -> DateTime64 precision tz -> Ordering
$c< :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> DateTime64 precision tz -> Bool
< :: DateTime64 precision tz -> DateTime64 precision tz -> Bool
$c<= :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> DateTime64 precision tz -> Bool
<= :: DateTime64 precision tz -> DateTime64 precision tz -> Bool
$c> :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> DateTime64 precision tz -> Bool
> :: DateTime64 precision tz -> DateTime64 precision tz -> Bool
$c>= :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> DateTime64 precision tz -> Bool
>= :: DateTime64 precision tz -> DateTime64 precision tz -> Bool
$cmax :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz
max :: DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz
$cmin :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz
min :: DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz
Ord, Num (DateTime64 precision tz)
Ord (DateTime64 precision tz)
(Num (DateTime64 precision tz), Ord (DateTime64 precision tz)) =>
(DateTime64 precision tz -> Rational)
-> Real (DateTime64 precision tz)
DateTime64 precision tz -> Rational
forall (precision :: Nat) (tz :: Symbol).
Num (DateTime64 precision tz)
forall (precision :: Nat) (tz :: Symbol).
Ord (DateTime64 precision tz)
forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> Rational
forall a. (Num a, Ord a) => (a -> Rational) -> Real a
$ctoRational :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> Rational
toRational :: DateTime64 precision tz -> Rational
Real, Enum (DateTime64 precision tz)
Real (DateTime64 precision tz)
(Real (DateTime64 precision tz), Enum (DateTime64 precision tz)) =>
(DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz)
-> (DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz)
-> (DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz)
-> (DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz)
-> (DateTime64 precision tz
-> DateTime64 precision tz
-> (DateTime64 precision tz, DateTime64 precision tz))
-> (DateTime64 precision tz
-> DateTime64 precision tz
-> (DateTime64 precision tz, DateTime64 precision tz))
-> (DateTime64 precision tz -> Integer)
-> Integral (DateTime64 precision tz)
DateTime64 precision tz -> Integer
DateTime64 precision tz
-> DateTime64 precision tz
-> (DateTime64 precision tz, DateTime64 precision tz)
DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz
forall (precision :: Nat) (tz :: Symbol).
Enum (DateTime64 precision tz)
forall (precision :: Nat) (tz :: Symbol).
Real (DateTime64 precision tz)
forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> Integer
forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz
-> DateTime64 precision tz
-> (DateTime64 precision tz, DateTime64 precision tz)
forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz
forall a.
(Real a, Enum a) =>
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> (a, a))
-> (a -> a -> (a, a))
-> (a -> Integer)
-> Integral a
$cquot :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz
quot :: DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz
$crem :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz
rem :: DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz
$cdiv :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz
div :: DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz
$cmod :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz
mod :: DateTime64 precision tz
-> DateTime64 precision tz -> DateTime64 precision tz
$cquotRem :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz
-> DateTime64 precision tz
-> (DateTime64 precision tz, DateTime64 precision tz)
quotRem :: DateTime64 precision tz
-> DateTime64 precision tz
-> (DateTime64 precision tz, DateTime64 precision tz)
$cdivMod :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz
-> DateTime64 precision tz
-> (DateTime64 precision tz, DateTime64 precision tz)
divMod :: DateTime64 precision tz
-> DateTime64 precision tz
-> (DateTime64 precision tz, DateTime64 precision tz)
$ctoInteger :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> Integer
toInteger :: DateTime64 precision tz -> Integer
Integral, DateTime64 precision tz
DateTime64 precision tz
-> DateTime64 precision tz -> Bounded (DateTime64 precision tz)
forall (precision :: Nat) (tz :: Symbol). DateTime64 precision tz
forall a. a -> a -> Bounded a
$cminBound :: forall (precision :: Nat) (tz :: Symbol). DateTime64 precision tz
minBound :: DateTime64 precision tz
$cmaxBound :: forall (precision :: Nat) (tz :: Symbol). DateTime64 precision tz
maxBound :: DateTime64 precision tz
Bounded, DateTime64 precision tz -> ()
(DateTime64 precision tz -> ()) -> NFData (DateTime64 precision tz)
forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> ()
forall a. (a -> ()) -> NFData a
$crnf :: forall (precision :: Nat) (tz :: Symbol).
DateTime64 precision tz -> ()
rnf :: DateTime64 precision tz -> ()
NFData)
instance
(KnownSymbol tz, KnownNat precision)
=>
IsChType (DateTime64 precision tz)
where
chTypeName :: String
chTypeName =
let
prec :: String
prec = Integer -> String
forall a. Show a => a -> String
show (forall (n :: Nat) (proxy :: Nat -> *).
KnownNat n =>
proxy n -> Integer
natVal @precision Proxy precision
forall {k} (t :: k). Proxy t
Proxy)
in
case forall (n :: Symbol) (proxy :: Symbol -> *).
KnownSymbol n =>
proxy n -> String
symbolVal @tz Proxy tz
forall {k} (t :: k). Proxy t
Proxy of
String
"" -> String
"DateTime64(" String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
prec String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
")"
String
tz -> String
"DateTime64(" String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
prec String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
", '" String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
tz String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
"')"
defaultValueOfTypeName :: DateTime64 precision tz
defaultValueOfTypeName = Word64 -> DateTime64 precision tz
forall (precision :: Nat) (tz :: Symbol).
Word64 -> DateTime64 precision tz
MkDateTime64 Word64
0
instance Serializable (DateTime64 precision tz) where
serialize :: ProtocolRevision -> DateTime64 precision tz -> Builder
serialize ProtocolRevision
_ (MkDateTime64 Word64
w64) = Word64 -> Builder
word64LE Word64
w64
deserialize :: ProtocolRevision -> Get (DateTime64 precision tz)
deserialize ProtocolRevision
_ = Word64 -> DateTime64 precision tz
forall (precision :: Nat) (tz :: Symbol).
Word64 -> DateTime64 precision tz
MkDateTime64 (Word64 -> DateTime64 precision tz)
-> Get Word64 -> Get (DateTime64 precision tz)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Word64
getWord64le
{-# INLINE deserialize #-}
instance ToChType (DateTime64 precision tz) Word64 where
toChType :: Word64 -> DateTime64 precision tz
toChType = Word64 -> DateTime64 precision tz
forall (precision :: Nat) (tz :: Symbol).
Word64 -> DateTime64 precision tz
MkDateTime64
fromChType :: DateTime64 precision tz -> Word64
fromChType (MkDateTime64 Word64
w64) = Word64
w64
instance KnownNat precision => ToChType (DateTime64 precision tz) UTCTime where
toChType :: UTCTime -> DateTime64 precision tz
toChType = Word64 -> DateTime64 precision tz
forall (precision :: Nat) (tz :: Symbol).
Word64 -> DateTime64 precision tz
MkDateTime64 (Word64 -> DateTime64 precision tz)
-> (UTCTime -> Word64) -> UTCTime -> DateTime64 precision tz
forall b c a. (b -> c) -> (a -> b) -> a -> c
. POSIXTime -> Word64
forall b. Integral b => POSIXTime -> b
forall a b. (RealFrac a, Integral b) => a -> b
floor (POSIXTime -> Word64)
-> (UTCTime -> POSIXTime) -> UTCTime -> Word64
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (POSIXTime -> POSIXTime -> POSIXTime
forall a. Num a => a -> a -> a
* (POSIXTime
10 POSIXTime -> Integer -> POSIXTime
forall a b. (Num a, Integral b) => a -> b -> a
^ Proxy precision -> Integer
forall (n :: Nat) (proxy :: Nat -> *).
KnownNat n =>
proxy n -> Integer
natVal (forall (t :: Nat). Proxy t
forall {k} (t :: k). Proxy t
Proxy @precision)))
(POSIXTime -> POSIXTime)
-> (UTCTime -> POSIXTime) -> UTCTime -> POSIXTime
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UTCTime -> POSIXTime
utcTimeToPOSIXSeconds
fromChType :: DateTime64 precision tz -> UTCTime
fromChType (MkDateTime64 Word64
w64) = POSIXTime -> UTCTime
posixSecondsToUTCTime
(POSIXTime -> UTCTime) -> POSIXTime -> UTCTime
forall a b. (a -> b) -> a -> b
$ (POSIXTime -> POSIXTime -> POSIXTime
forall a. Fractional a => a -> a -> a
/ (POSIXTime
10 POSIXTime -> Integer -> POSIXTime
forall a b. (Num a, Integral b) => a -> b -> a
^ Proxy precision -> Integer
forall (n :: Nat) (proxy :: Nat -> *).
KnownNat n =>
proxy n -> Integer
natVal (forall (t :: Nat). Proxy t
forall {k} (t :: k). Proxy t
Proxy @precision))) (POSIXTime -> POSIXTime) -> POSIXTime -> POSIXTime
forall a b. (a -> b) -> a -> b
$ Word64 -> POSIXTime
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word64
w64