{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc)

A date and time. The date is assumed to be in the (proleptic)
Gregorian calendar. The time is in UTC if /@utc@/ is 'True'. Otherwise,
the time is a local time, and /@offset@/ gives the offset from UTC in
minutes (such that adding /@offset@/ to the time would give the
correct UTC time). If /@utc@/ is 'False' and /@offset@/ is 0, then the
@/SoupDate/@ represents a \"floating\" time with no associated timezone
information.
-}

#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
       && !defined(__HADDOCK_VERSION__))

module GI.Soup.Structs.Date
    (

-- * Exported types
    Date(..)                                ,
    newZeroDate                             ,
    noDate                                  ,


 -- * Methods
-- ** copy #method:copy#

#if ENABLE_OVERLOADING
    DateCopyMethodInfo                      ,
#endif
    dateCopy                                ,


-- ** free #method:free#

#if ENABLE_OVERLOADING
    DateFreeMethodInfo                      ,
#endif
    dateFree                                ,


-- ** getDay #method:getDay#

#if ENABLE_OVERLOADING
    DateGetDayMethodInfo                    ,
#endif
    dateGetDay                              ,


-- ** getHour #method:getHour#

#if ENABLE_OVERLOADING
    DateGetHourMethodInfo                   ,
#endif
    dateGetHour                             ,


-- ** getMinute #method:getMinute#

#if ENABLE_OVERLOADING
    DateGetMinuteMethodInfo                 ,
#endif
    dateGetMinute                           ,


-- ** getMonth #method:getMonth#

#if ENABLE_OVERLOADING
    DateGetMonthMethodInfo                  ,
#endif
    dateGetMonth                            ,


-- ** getOffset #method:getOffset#

#if ENABLE_OVERLOADING
    DateGetOffsetMethodInfo                 ,
#endif
    dateGetOffset                           ,


-- ** getSecond #method:getSecond#

#if ENABLE_OVERLOADING
    DateGetSecondMethodInfo                 ,
#endif
    dateGetSecond                           ,


-- ** getUtc #method:getUtc#

#if ENABLE_OVERLOADING
    DateGetUtcMethodInfo                    ,
#endif
    dateGetUtc                              ,


-- ** getYear #method:getYear#

#if ENABLE_OVERLOADING
    DateGetYearMethodInfo                   ,
#endif
    dateGetYear                             ,


-- ** isPast #method:isPast#

#if ENABLE_OVERLOADING
    DateIsPastMethodInfo                    ,
#endif
    dateIsPast                              ,


-- ** new #method:new#

    dateNew                                 ,


-- ** newFromNow #method:newFromNow#

    dateNewFromNow                          ,


-- ** newFromString #method:newFromString#

    dateNewFromString                       ,


-- ** newFromTimeT #method:newFromTimeT#

    dateNewFromTimeT                        ,


-- ** toString #method:toString#

#if ENABLE_OVERLOADING
    DateToStringMethodInfo                  ,
#endif
    dateToString                            ,


-- ** toTimeT #method:toTimeT#

#if ENABLE_OVERLOADING
    DateToTimeTMethodInfo                   ,
#endif
    dateToTimeT                             ,


-- ** toTimeval #method:toTimeval#

#if ENABLE_OVERLOADING
    DateToTimevalMethodInfo                 ,
#endif
    dateToTimeval                           ,




 -- * Properties
-- ** day #attr:day#
{- | day of the month, 1 to 31
-}
#if ENABLE_OVERLOADING
    date_day                                ,
#endif
    getDateDay                              ,
    setDateDay                              ,


-- ** hour #attr:hour#
{- | hour of the day, 0 to 23
-}
#if ENABLE_OVERLOADING
    date_hour                               ,
#endif
    getDateHour                             ,
    setDateHour                             ,


-- ** minute #attr:minute#
{- | minute, 0 to 59
-}
#if ENABLE_OVERLOADING
    date_minute                             ,
#endif
    getDateMinute                           ,
    setDateMinute                           ,


-- ** month #attr:month#
{- | the month, 1 to 12
-}
#if ENABLE_OVERLOADING
    date_month                              ,
#endif
    getDateMonth                            ,
    setDateMonth                            ,


-- ** offset #attr:offset#
{- | offset from UTC
-}
#if ENABLE_OVERLOADING
    date_offset                             ,
#endif
    getDateOffset                           ,
    setDateOffset                           ,


-- ** second #attr:second#
{- | second, 0 to 59 (or up to 61 in the case of leap seconds)
-}
#if ENABLE_OVERLOADING
    date_second                             ,
#endif
    getDateSecond                           ,
    setDateSecond                           ,


-- ** utc #attr:utc#
{- | 'True' if the date is in UTC
-}
#if ENABLE_OVERLOADING
    date_utc                                ,
#endif
    getDateUtc                              ,
    setDateUtc                              ,


-- ** year #attr:year#
{- | the year, 1 to 9999
-}
#if ENABLE_OVERLOADING
    date_year                               ,
#endif
    getDateYear                             ,
    setDateYear                             ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL

import qualified GI.GLib.Structs.TimeVal as GLib.TimeVal
import {-# SOURCE #-} qualified GI.Soup.Enums as Soup.Enums

-- | Memory-managed wrapper type.
newtype Date = Date (ManagedPtr Date)
foreign import ccall "soup_date_get_type" c_soup_date_get_type ::
    IO GType

instance BoxedObject Date where
    boxedType _ = c_soup_date_get_type

-- | Construct a `Date` struct initialized to zero.
newZeroDate :: MonadIO m => m Date
newZeroDate = liftIO $ callocBoxedBytes 32 >>= wrapBoxed Date

instance tag ~ 'AttrSet => Constructible Date tag where
    new _ attrs = do
        o <- newZeroDate
        GI.Attributes.set o attrs
        return o


-- | A convenience alias for `Nothing` :: `Maybe` `Date`.
noDate :: Maybe Date
noDate = Nothing

{- |
Get the value of the “@year@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' date #year
@
-}
getDateYear :: MonadIO m => Date -> m Int32
getDateYear s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO Int32
    return val

{- |
Set the value of the “@year@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' date [ #year 'Data.GI.Base.Attributes.:=' value ]
@
-}
setDateYear :: MonadIO m => Date -> Int32 -> m ()
setDateYear s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 0) (val :: Int32)

#if ENABLE_OVERLOADING
data DateYearFieldInfo
instance AttrInfo DateYearFieldInfo where
    type AttrAllowedOps DateYearFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint DateYearFieldInfo = (~) Int32
    type AttrBaseTypeConstraint DateYearFieldInfo = (~) Date
    type AttrGetType DateYearFieldInfo = Int32
    type AttrLabel DateYearFieldInfo = "year"
    type AttrOrigin DateYearFieldInfo = Date
    attrGet _ = getDateYear
    attrSet _ = setDateYear
    attrConstruct = undefined
    attrClear _ = undefined

date_year :: AttrLabelProxy "year"
date_year = AttrLabelProxy

#endif


{- |
Get the value of the “@month@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' date #month
@
-}
getDateMonth :: MonadIO m => Date -> m Int32
getDateMonth s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 4) :: IO Int32
    return val

{- |
Set the value of the “@month@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' date [ #month 'Data.GI.Base.Attributes.:=' value ]
@
-}
setDateMonth :: MonadIO m => Date -> Int32 -> m ()
setDateMonth s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 4) (val :: Int32)

#if ENABLE_OVERLOADING
data DateMonthFieldInfo
instance AttrInfo DateMonthFieldInfo where
    type AttrAllowedOps DateMonthFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint DateMonthFieldInfo = (~) Int32
    type AttrBaseTypeConstraint DateMonthFieldInfo = (~) Date
    type AttrGetType DateMonthFieldInfo = Int32
    type AttrLabel DateMonthFieldInfo = "month"
    type AttrOrigin DateMonthFieldInfo = Date
    attrGet _ = getDateMonth
    attrSet _ = setDateMonth
    attrConstruct = undefined
    attrClear _ = undefined

date_month :: AttrLabelProxy "month"
date_month = AttrLabelProxy

#endif


{- |
Get the value of the “@day@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' date #day
@
-}
getDateDay :: MonadIO m => Date -> m Int32
getDateDay s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 8) :: IO Int32
    return val

{- |
Set the value of the “@day@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' date [ #day 'Data.GI.Base.Attributes.:=' value ]
@
-}
setDateDay :: MonadIO m => Date -> Int32 -> m ()
setDateDay s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 8) (val :: Int32)

#if ENABLE_OVERLOADING
data DateDayFieldInfo
instance AttrInfo DateDayFieldInfo where
    type AttrAllowedOps DateDayFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint DateDayFieldInfo = (~) Int32
    type AttrBaseTypeConstraint DateDayFieldInfo = (~) Date
    type AttrGetType DateDayFieldInfo = Int32
    type AttrLabel DateDayFieldInfo = "day"
    type AttrOrigin DateDayFieldInfo = Date
    attrGet _ = getDateDay
    attrSet _ = setDateDay
    attrConstruct = undefined
    attrClear _ = undefined

date_day :: AttrLabelProxy "day"
date_day = AttrLabelProxy

#endif


{- |
Get the value of the “@hour@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' date #hour
@
-}
getDateHour :: MonadIO m => Date -> m Int32
getDateHour s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 12) :: IO Int32
    return val

{- |
Set the value of the “@hour@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' date [ #hour 'Data.GI.Base.Attributes.:=' value ]
@
-}
setDateHour :: MonadIO m => Date -> Int32 -> m ()
setDateHour s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 12) (val :: Int32)

#if ENABLE_OVERLOADING
data DateHourFieldInfo
instance AttrInfo DateHourFieldInfo where
    type AttrAllowedOps DateHourFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint DateHourFieldInfo = (~) Int32
    type AttrBaseTypeConstraint DateHourFieldInfo = (~) Date
    type AttrGetType DateHourFieldInfo = Int32
    type AttrLabel DateHourFieldInfo = "hour"
    type AttrOrigin DateHourFieldInfo = Date
    attrGet _ = getDateHour
    attrSet _ = setDateHour
    attrConstruct = undefined
    attrClear _ = undefined

date_hour :: AttrLabelProxy "hour"
date_hour = AttrLabelProxy

#endif


{- |
Get the value of the “@minute@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' date #minute
@
-}
getDateMinute :: MonadIO m => Date -> m Int32
getDateMinute s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 16) :: IO Int32
    return val

{- |
Set the value of the “@minute@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' date [ #minute 'Data.GI.Base.Attributes.:=' value ]
@
-}
setDateMinute :: MonadIO m => Date -> Int32 -> m ()
setDateMinute s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 16) (val :: Int32)

#if ENABLE_OVERLOADING
data DateMinuteFieldInfo
instance AttrInfo DateMinuteFieldInfo where
    type AttrAllowedOps DateMinuteFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint DateMinuteFieldInfo = (~) Int32
    type AttrBaseTypeConstraint DateMinuteFieldInfo = (~) Date
    type AttrGetType DateMinuteFieldInfo = Int32
    type AttrLabel DateMinuteFieldInfo = "minute"
    type AttrOrigin DateMinuteFieldInfo = Date
    attrGet _ = getDateMinute
    attrSet _ = setDateMinute
    attrConstruct = undefined
    attrClear _ = undefined

date_minute :: AttrLabelProxy "minute"
date_minute = AttrLabelProxy

#endif


{- |
Get the value of the “@second@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' date #second
@
-}
getDateSecond :: MonadIO m => Date -> m Int32
getDateSecond s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 20) :: IO Int32
    return val

{- |
Set the value of the “@second@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' date [ #second 'Data.GI.Base.Attributes.:=' value ]
@
-}
setDateSecond :: MonadIO m => Date -> Int32 -> m ()
setDateSecond s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 20) (val :: Int32)

#if ENABLE_OVERLOADING
data DateSecondFieldInfo
instance AttrInfo DateSecondFieldInfo where
    type AttrAllowedOps DateSecondFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint DateSecondFieldInfo = (~) Int32
    type AttrBaseTypeConstraint DateSecondFieldInfo = (~) Date
    type AttrGetType DateSecondFieldInfo = Int32
    type AttrLabel DateSecondFieldInfo = "second"
    type AttrOrigin DateSecondFieldInfo = Date
    attrGet _ = getDateSecond
    attrSet _ = setDateSecond
    attrConstruct = undefined
    attrClear _ = undefined

date_second :: AttrLabelProxy "second"
date_second = AttrLabelProxy

#endif


{- |
Get the value of the “@utc@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' date #utc
@
-}
getDateUtc :: MonadIO m => Date -> m Bool
getDateUtc s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 24) :: IO CInt
    let val' = (/= 0) val
    return val'

{- |
Set the value of the “@utc@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' date [ #utc 'Data.GI.Base.Attributes.:=' value ]
@
-}
setDateUtc :: MonadIO m => Date -> Bool -> m ()
setDateUtc s val = liftIO $ withManagedPtr s $ \ptr -> do
    let val' = (fromIntegral . fromEnum) val
    poke (ptr `plusPtr` 24) (val' :: CInt)

#if ENABLE_OVERLOADING
data DateUtcFieldInfo
instance AttrInfo DateUtcFieldInfo where
    type AttrAllowedOps DateUtcFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint DateUtcFieldInfo = (~) Bool
    type AttrBaseTypeConstraint DateUtcFieldInfo = (~) Date
    type AttrGetType DateUtcFieldInfo = Bool
    type AttrLabel DateUtcFieldInfo = "utc"
    type AttrOrigin DateUtcFieldInfo = Date
    attrGet _ = getDateUtc
    attrSet _ = setDateUtc
    attrConstruct = undefined
    attrClear _ = undefined

date_utc :: AttrLabelProxy "utc"
date_utc = AttrLabelProxy

#endif


{- |
Get the value of the “@offset@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' date #offset
@
-}
getDateOffset :: MonadIO m => Date -> m Int32
getDateOffset s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 28) :: IO Int32
    return val

{- |
Set the value of the “@offset@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' date [ #offset 'Data.GI.Base.Attributes.:=' value ]
@
-}
setDateOffset :: MonadIO m => Date -> Int32 -> m ()
setDateOffset s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 28) (val :: Int32)

#if ENABLE_OVERLOADING
data DateOffsetFieldInfo
instance AttrInfo DateOffsetFieldInfo where
    type AttrAllowedOps DateOffsetFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint DateOffsetFieldInfo = (~) Int32
    type AttrBaseTypeConstraint DateOffsetFieldInfo = (~) Date
    type AttrGetType DateOffsetFieldInfo = Int32
    type AttrLabel DateOffsetFieldInfo = "offset"
    type AttrOrigin DateOffsetFieldInfo = Date
    attrGet _ = getDateOffset
    attrSet _ = setDateOffset
    attrConstruct = undefined
    attrClear _ = undefined

date_offset :: AttrLabelProxy "offset"
date_offset = AttrLabelProxy

#endif



#if ENABLE_OVERLOADING
instance O.HasAttributeList Date
type instance O.AttributeList Date = DateAttributeList
type DateAttributeList = ('[ '("year", DateYearFieldInfo), '("month", DateMonthFieldInfo), '("day", DateDayFieldInfo), '("hour", DateHourFieldInfo), '("minute", DateMinuteFieldInfo), '("second", DateSecondFieldInfo), '("utc", DateUtcFieldInfo), '("offset", DateOffsetFieldInfo)] :: [(Symbol, *)])
#endif

-- method Date::new
-- method type : Constructor
-- Args : [Arg {argCName = "year", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the year (1-9999)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "month", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the month (1-12)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "day", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the day of the month (1-31, as appropriate for @month)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "hour", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the hour (0-23)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "minute", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the minute (0-59)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "second", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the second (0-59, or up to 61 for leap seconds)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Soup", name = "Date"}))
-- throws : False
-- Skip return : False

foreign import ccall "soup_date_new" soup_date_new ::
    Int32 ->                                -- year : TBasicType TInt
    Int32 ->                                -- month : TBasicType TInt
    Int32 ->                                -- day : TBasicType TInt
    Int32 ->                                -- hour : TBasicType TInt
    Int32 ->                                -- minute : TBasicType TInt
    Int32 ->                                -- second : TBasicType TInt
    IO (Ptr Date)

{- |
Creates a 'GI.Soup.Structs.Date.Date' representing the indicated time, UTC.
-}
dateNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Int32
    {- ^ /@year@/: the year (1-9999) -}
    -> Int32
    {- ^ /@month@/: the month (1-12) -}
    -> Int32
    {- ^ /@day@/: the day of the month (1-31, as appropriate for /@month@/) -}
    -> Int32
    {- ^ /@hour@/: the hour (0-23) -}
    -> Int32
    {- ^ /@minute@/: the minute (0-59) -}
    -> Int32
    {- ^ /@second@/: the second (0-59, or up to 61 for leap seconds) -}
    -> m Date
    {- ^ __Returns:__ a new 'GI.Soup.Structs.Date.Date' -}
dateNew year month day hour minute second = liftIO $ do
    result <- soup_date_new year month day hour minute second
    checkUnexpectedReturnNULL "dateNew" result
    result' <- (wrapBoxed Date) result
    return result'

#if ENABLE_OVERLOADING
#endif

-- method Date::new_from_now
-- method type : Constructor
-- Args : [Arg {argCName = "offset_seconds", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "offset from current time", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Soup", name = "Date"}))
-- throws : False
-- Skip return : False

foreign import ccall "soup_date_new_from_now" soup_date_new_from_now ::
    Int32 ->                                -- offset_seconds : TBasicType TInt
    IO (Ptr Date)

{- |
Creates a 'GI.Soup.Structs.Date.Date' representing a time /@offsetSeconds@/ after the
current time (or before it, if /@offsetSeconds@/ is negative). If
offset_seconds is 0, returns the current time.

If /@offsetSeconds@/ would indicate a time not expressible as a
\<type>time_t\<\/type>, the return value will be clamped into range.
-}
dateNewFromNow ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Int32
    {- ^ /@offsetSeconds@/: offset from current time -}
    -> m Date
    {- ^ __Returns:__ a new 'GI.Soup.Structs.Date.Date' -}
dateNewFromNow offsetSeconds = liftIO $ do
    result <- soup_date_new_from_now offsetSeconds
    checkUnexpectedReturnNULL "dateNewFromNow" result
    result' <- (wrapBoxed Date) result
    return result'

#if ENABLE_OVERLOADING
#endif

-- method Date::new_from_string
-- method type : Constructor
-- Args : [Arg {argCName = "date_string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the date in some plausible format", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Soup", name = "Date"}))
-- throws : False
-- Skip return : False

foreign import ccall "soup_date_new_from_string" soup_date_new_from_string ::
    CString ->                              -- date_string : TBasicType TUTF8
    IO (Ptr Date)

{- |
Parses /@dateString@/ and tries to extract a date from it. This
recognizes all of the \"HTTP-date\" formats from RFC 2616, all ISO
8601 formats containing both a time and a date, RFC 2822 dates,
and reasonable approximations thereof. (Eg, it is lenient about
whitespace, leading \"0\"s, etc.)
-}
dateNewFromString ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@dateString@/: the date in some plausible format -}
    -> m (Maybe Date)
    {- ^ __Returns:__ a new 'GI.Soup.Structs.Date.Date', or 'Nothing' if /@dateString@/
could not be parsed. -}
dateNewFromString dateString = liftIO $ do
    dateString' <- textToCString dateString
    result <- soup_date_new_from_string dateString'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapBoxed Date) result'
        return result''
    freeMem dateString'
    return maybeResult

#if ENABLE_OVERLOADING
#endif

-- method Date::new_from_time_t
-- method type : Constructor
-- Args : [Arg {argCName = "when", argType = TBasicType TLong, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a <type>time_t</type>", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Soup", name = "Date"}))
-- throws : False
-- Skip return : False

foreign import ccall "soup_date_new_from_time_t" soup_date_new_from_time_t ::
    CLong ->                                -- when : TBasicType TLong
    IO (Ptr Date)

{- |
Creates a 'GI.Soup.Structs.Date.Date' corresponding to /@when@/
-}
dateNewFromTimeT ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    CLong
    {- ^ /@when@/: a \<type>time_t\<\/type> -}
    -> m Date
    {- ^ __Returns:__ a new 'GI.Soup.Structs.Date.Date' -}
dateNewFromTimeT when_ = liftIO $ do
    result <- soup_date_new_from_time_t when_
    checkUnexpectedReturnNULL "dateNewFromTimeT" result
    result' <- (wrapBoxed Date) result
    return result'

#if ENABLE_OVERLOADING
#endif

-- method Date::copy
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "date", argType = TInterface (Name {namespace = "Soup", name = "Date"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupDate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Soup", name = "Date"}))
-- throws : False
-- Skip return : False

foreign import ccall "soup_date_copy" soup_date_copy ::
    Ptr Date ->                             -- date : TInterface (Name {namespace = "Soup", name = "Date"})
    IO (Ptr Date)

{- |
Copies /@date@/.

/Since: 2.24/
-}
dateCopy ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Date
    {- ^ /@date@/: a 'GI.Soup.Structs.Date.Date' -}
    -> m Date
dateCopy date = liftIO $ do
    date' <- unsafeManagedPtrGetPtr date
    result <- soup_date_copy date'
    checkUnexpectedReturnNULL "dateCopy" result
    result' <- (wrapBoxed Date) result
    touchManagedPtr date
    return result'

#if ENABLE_OVERLOADING
data DateCopyMethodInfo
instance (signature ~ (m Date), MonadIO m) => O.MethodInfo DateCopyMethodInfo Date signature where
    overloadedMethod _ = dateCopy

#endif

-- method Date::free
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "date", argType = TInterface (Name {namespace = "Soup", name = "Date"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupDate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "soup_date_free" soup_date_free ::
    Ptr Date ->                             -- date : TInterface (Name {namespace = "Soup", name = "Date"})
    IO ()

{- |
Frees /@date@/.

/Since: 2.24/
-}
dateFree ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Date
    {- ^ /@date@/: a 'GI.Soup.Structs.Date.Date' -}
    -> m ()
dateFree date = liftIO $ do
    date' <- unsafeManagedPtrGetPtr date
    soup_date_free date'
    touchManagedPtr date
    return ()

#if ENABLE_OVERLOADING
data DateFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo DateFreeMethodInfo Date signature where
    overloadedMethod _ = dateFree

#endif

-- method Date::get_day
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "date", argType = TInterface (Name {namespace = "Soup", name = "Date"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupDate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "soup_date_get_day" soup_date_get_day ::
    Ptr Date ->                             -- date : TInterface (Name {namespace = "Soup", name = "Date"})
    IO Int32

{- |
Gets /@date@/\'s day.

/Since: 2.32/
-}
dateGetDay ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Date
    {- ^ /@date@/: a 'GI.Soup.Structs.Date.Date' -}
    -> m Int32
    {- ^ __Returns:__ /@date@/\'s day -}
dateGetDay date = liftIO $ do
    date' <- unsafeManagedPtrGetPtr date
    result <- soup_date_get_day date'
    touchManagedPtr date
    return result

#if ENABLE_OVERLOADING
data DateGetDayMethodInfo
instance (signature ~ (m Int32), MonadIO m) => O.MethodInfo DateGetDayMethodInfo Date signature where
    overloadedMethod _ = dateGetDay

#endif

-- method Date::get_hour
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "date", argType = TInterface (Name {namespace = "Soup", name = "Date"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupDate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "soup_date_get_hour" soup_date_get_hour ::
    Ptr Date ->                             -- date : TInterface (Name {namespace = "Soup", name = "Date"})
    IO Int32

{- |
Gets /@date@/\'s hour.

/Since: 2.32/
-}
dateGetHour ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Date
    {- ^ /@date@/: a 'GI.Soup.Structs.Date.Date' -}
    -> m Int32
    {- ^ __Returns:__ /@date@/\'s hour -}
dateGetHour date = liftIO $ do
    date' <- unsafeManagedPtrGetPtr date
    result <- soup_date_get_hour date'
    touchManagedPtr date
    return result

#if ENABLE_OVERLOADING
data DateGetHourMethodInfo
instance (signature ~ (m Int32), MonadIO m) => O.MethodInfo DateGetHourMethodInfo Date signature where
    overloadedMethod _ = dateGetHour

#endif

-- method Date::get_minute
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "date", argType = TInterface (Name {namespace = "Soup", name = "Date"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupDate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "soup_date_get_minute" soup_date_get_minute ::
    Ptr Date ->                             -- date : TInterface (Name {namespace = "Soup", name = "Date"})
    IO Int32

{- |
Gets /@date@/\'s minute.

/Since: 2.32/
-}
dateGetMinute ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Date
    {- ^ /@date@/: a 'GI.Soup.Structs.Date.Date' -}
    -> m Int32
    {- ^ __Returns:__ /@date@/\'s minute -}
dateGetMinute date = liftIO $ do
    date' <- unsafeManagedPtrGetPtr date
    result <- soup_date_get_minute date'
    touchManagedPtr date
    return result

#if ENABLE_OVERLOADING
data DateGetMinuteMethodInfo
instance (signature ~ (m Int32), MonadIO m) => O.MethodInfo DateGetMinuteMethodInfo Date signature where
    overloadedMethod _ = dateGetMinute

#endif

-- method Date::get_month
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "date", argType = TInterface (Name {namespace = "Soup", name = "Date"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupDate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "soup_date_get_month" soup_date_get_month ::
    Ptr Date ->                             -- date : TInterface (Name {namespace = "Soup", name = "Date"})
    IO Int32

{- |
Gets /@date@/\'s month.

/Since: 2.32/
-}
dateGetMonth ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Date
    {- ^ /@date@/: a 'GI.Soup.Structs.Date.Date' -}
    -> m Int32
    {- ^ __Returns:__ /@date@/\'s month -}
dateGetMonth date = liftIO $ do
    date' <- unsafeManagedPtrGetPtr date
    result <- soup_date_get_month date'
    touchManagedPtr date
    return result

#if ENABLE_OVERLOADING
data DateGetMonthMethodInfo
instance (signature ~ (m Int32), MonadIO m) => O.MethodInfo DateGetMonthMethodInfo Date signature where
    overloadedMethod _ = dateGetMonth

#endif

-- method Date::get_offset
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "date", argType = TInterface (Name {namespace = "Soup", name = "Date"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupDate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "soup_date_get_offset" soup_date_get_offset ::
    Ptr Date ->                             -- date : TInterface (Name {namespace = "Soup", name = "Date"})
    IO Int32

{- |
Gets /@date@/\'s offset from UTC.

/Since: 2.32/
-}
dateGetOffset ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Date
    {- ^ /@date@/: a 'GI.Soup.Structs.Date.Date' -}
    -> m Int32
    {- ^ __Returns:__ /@date@/\'s offset from UTC. If 'GI.Soup.Structs.Date.dateGetUtc'
returns 'False' but 'GI.Soup.Structs.Date.dateGetOffset' returns 0, that means the
date is a \"floating\" time with no associated offset information. -}
dateGetOffset date = liftIO $ do
    date' <- unsafeManagedPtrGetPtr date
    result <- soup_date_get_offset date'
    touchManagedPtr date
    return result

#if ENABLE_OVERLOADING
data DateGetOffsetMethodInfo
instance (signature ~ (m Int32), MonadIO m) => O.MethodInfo DateGetOffsetMethodInfo Date signature where
    overloadedMethod _ = dateGetOffset

#endif

-- method Date::get_second
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "date", argType = TInterface (Name {namespace = "Soup", name = "Date"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupDate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "soup_date_get_second" soup_date_get_second ::
    Ptr Date ->                             -- date : TInterface (Name {namespace = "Soup", name = "Date"})
    IO Int32

{- |
Gets /@date@/\'s second.

/Since: 2.32/
-}
dateGetSecond ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Date
    {- ^ /@date@/: a 'GI.Soup.Structs.Date.Date' -}
    -> m Int32
    {- ^ __Returns:__ /@date@/\'s second -}
dateGetSecond date = liftIO $ do
    date' <- unsafeManagedPtrGetPtr date
    result <- soup_date_get_second date'
    touchManagedPtr date
    return result

#if ENABLE_OVERLOADING
data DateGetSecondMethodInfo
instance (signature ~ (m Int32), MonadIO m) => O.MethodInfo DateGetSecondMethodInfo Date signature where
    overloadedMethod _ = dateGetSecond

#endif

-- method Date::get_utc
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "date", argType = TInterface (Name {namespace = "Soup", name = "Date"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupDate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "soup_date_get_utc" soup_date_get_utc ::
    Ptr Date ->                             -- date : TInterface (Name {namespace = "Soup", name = "Date"})
    IO Int32

{- |
Gets /@date@/\'s UTC flag

/Since: 2.32/
-}
dateGetUtc ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Date
    {- ^ /@date@/: a 'GI.Soup.Structs.Date.Date' -}
    -> m Int32
    {- ^ __Returns:__ 'True' if /@date@/ is UTC. -}
dateGetUtc date = liftIO $ do
    date' <- unsafeManagedPtrGetPtr date
    result <- soup_date_get_utc date'
    touchManagedPtr date
    return result

#if ENABLE_OVERLOADING
data DateGetUtcMethodInfo
instance (signature ~ (m Int32), MonadIO m) => O.MethodInfo DateGetUtcMethodInfo Date signature where
    overloadedMethod _ = dateGetUtc

#endif

-- method Date::get_year
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "date", argType = TInterface (Name {namespace = "Soup", name = "Date"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupDate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "soup_date_get_year" soup_date_get_year ::
    Ptr Date ->                             -- date : TInterface (Name {namespace = "Soup", name = "Date"})
    IO Int32

{- |
Gets /@date@/\'s year.

/Since: 2.32/
-}
dateGetYear ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Date
    {- ^ /@date@/: a 'GI.Soup.Structs.Date.Date' -}
    -> m Int32
    {- ^ __Returns:__ /@date@/\'s year -}
dateGetYear date = liftIO $ do
    date' <- unsafeManagedPtrGetPtr date
    result <- soup_date_get_year date'
    touchManagedPtr date
    return result

#if ENABLE_OVERLOADING
data DateGetYearMethodInfo
instance (signature ~ (m Int32), MonadIO m) => O.MethodInfo DateGetYearMethodInfo Date signature where
    overloadedMethod _ = dateGetYear

#endif

-- method Date::is_past
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "date", argType = TInterface (Name {namespace = "Soup", name = "Date"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupDate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "soup_date_is_past" soup_date_is_past ::
    Ptr Date ->                             -- date : TInterface (Name {namespace = "Soup", name = "Date"})
    IO CInt

{- |
Determines if /@date@/ is in the past.

/Since: 2.24/
-}
dateIsPast ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Date
    {- ^ /@date@/: a 'GI.Soup.Structs.Date.Date' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@date@/ is in the past -}
dateIsPast date = liftIO $ do
    date' <- unsafeManagedPtrGetPtr date
    result <- soup_date_is_past date'
    let result' = (/= 0) result
    touchManagedPtr date
    return result'

#if ENABLE_OVERLOADING
data DateIsPastMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo DateIsPastMethodInfo Date signature where
    overloadedMethod _ = dateIsPast

#endif

-- method Date::to_string
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "date", argType = TInterface (Name {namespace = "Soup", name = "Date"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupDate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "format", argType = TInterface (Name {namespace = "Soup", name = "DateFormat"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the format to generate the date in", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "soup_date_to_string" soup_date_to_string ::
    Ptr Date ->                             -- date : TInterface (Name {namespace = "Soup", name = "Date"})
    CUInt ->                                -- format : TInterface (Name {namespace = "Soup", name = "DateFormat"})
    IO CString

{- |
Converts /@date@/ to a string in the format described by /@format@/.
-}
dateToString ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Date
    {- ^ /@date@/: a 'GI.Soup.Structs.Date.Date' -}
    -> Soup.Enums.DateFormat
    {- ^ /@format@/: the format to generate the date in -}
    -> m T.Text
    {- ^ __Returns:__ /@date@/ as a string -}
dateToString date format = liftIO $ do
    date' <- unsafeManagedPtrGetPtr date
    let format' = (fromIntegral . fromEnum) format
    result <- soup_date_to_string date' format'
    checkUnexpectedReturnNULL "dateToString" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr date
    return result'

#if ENABLE_OVERLOADING
data DateToStringMethodInfo
instance (signature ~ (Soup.Enums.DateFormat -> m T.Text), MonadIO m) => O.MethodInfo DateToStringMethodInfo Date signature where
    overloadedMethod _ = dateToString

#endif

-- method Date::to_time_t
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "date", argType = TInterface (Name {namespace = "Soup", name = "Date"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupDate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TLong)
-- throws : False
-- Skip return : False

foreign import ccall "soup_date_to_time_t" soup_date_to_time_t ::
    Ptr Date ->                             -- date : TInterface (Name {namespace = "Soup", name = "Date"})
    IO CLong

{- |
Converts /@date@/ to a \<type>time_t\<\/type>.

If /@date@/ is not representable as a \<type>time_t\<\/type>, it will be
clamped into range. (In particular, some HTTP cookies have
expiration dates after \"Y2.038k\" (2038-01-19T03:14:07Z).)
-}
dateToTimeT ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Date
    {- ^ /@date@/: a 'GI.Soup.Structs.Date.Date' -}
    -> m CLong
    {- ^ __Returns:__ /@date@/ as a \<type>time_t\<\/type> -}
dateToTimeT date = liftIO $ do
    date' <- unsafeManagedPtrGetPtr date
    result <- soup_date_to_time_t date'
    touchManagedPtr date
    return result

#if ENABLE_OVERLOADING
data DateToTimeTMethodInfo
instance (signature ~ (m CLong), MonadIO m) => O.MethodInfo DateToTimeTMethodInfo Date signature where
    overloadedMethod _ = dateToTimeT

#endif

-- method Date::to_timeval
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "date", argType = TInterface (Name {namespace = "Soup", name = "Date"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupDate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "time", argType = TInterface (Name {namespace = "GLib", name = "TimeVal"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTimeVal structure in which to store the converted time.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = True, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "soup_date_to_timeval" soup_date_to_timeval ::
    Ptr Date ->                             -- date : TInterface (Name {namespace = "Soup", name = "Date"})
    Ptr GLib.TimeVal.TimeVal ->             -- time : TInterface (Name {namespace = "GLib", name = "TimeVal"})
    IO ()

{- |
Converts /@date@/ to a 'GI.GLib.Structs.TimeVal.TimeVal'.

/Since: 2.24/
-}
dateToTimeval ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Date
    {- ^ /@date@/: a 'GI.Soup.Structs.Date.Date' -}
    -> m (GLib.TimeVal.TimeVal)
dateToTimeval date = liftIO $ do
    date' <- unsafeManagedPtrGetPtr date
    time <- callocBytes 16 :: IO (Ptr GLib.TimeVal.TimeVal)
    soup_date_to_timeval date' time
    time' <- (wrapPtr GLib.TimeVal.TimeVal) time
    touchManagedPtr date
    return time'

#if ENABLE_OVERLOADING
data DateToTimevalMethodInfo
instance (signature ~ (m (GLib.TimeVal.TimeVal)), MonadIO m) => O.MethodInfo DateToTimevalMethodInfo Date signature where
    overloadedMethod _ = dateToTimeval

#endif

#if ENABLE_OVERLOADING
type family ResolveDateMethod (t :: Symbol) (o :: *) :: * where
    ResolveDateMethod "copy" o = DateCopyMethodInfo
    ResolveDateMethod "free" o = DateFreeMethodInfo
    ResolveDateMethod "isPast" o = DateIsPastMethodInfo
    ResolveDateMethod "toString" o = DateToStringMethodInfo
    ResolveDateMethod "toTimeT" o = DateToTimeTMethodInfo
    ResolveDateMethod "toTimeval" o = DateToTimevalMethodInfo
    ResolveDateMethod "getDay" o = DateGetDayMethodInfo
    ResolveDateMethod "getHour" o = DateGetHourMethodInfo
    ResolveDateMethod "getMinute" o = DateGetMinuteMethodInfo
    ResolveDateMethod "getMonth" o = DateGetMonthMethodInfo
    ResolveDateMethod "getOffset" o = DateGetOffsetMethodInfo
    ResolveDateMethod "getSecond" o = DateGetSecondMethodInfo
    ResolveDateMethod "getUtc" o = DateGetUtcMethodInfo
    ResolveDateMethod "getYear" o = DateGetYearMethodInfo
    ResolveDateMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveDateMethod t Date, O.MethodInfo info Date p) => OL.IsLabel t (Date -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

#endif