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

'GI.GLib.Structs.TimeZone.TimeZone' is an opaque structure whose members cannot be accessed
directly.

/Since: 2.26/
-}

#define ENABLE_OVERLOADING \
       (!defined(__HADDOCK_VERSION__))

module GI.GLib.Structs.TimeZone
    ( 

-- * Exported types
    TimeZone(..)                            ,
    noTimeZone                              ,


 -- * Methods
-- ** adjustTime #method:adjustTime#

#if ENABLE_OVERLOADING
    TimeZoneAdjustTimeMethodInfo            ,
#endif
    timeZoneAdjustTime                      ,


-- ** findInterval #method:findInterval#

#if ENABLE_OVERLOADING
    TimeZoneFindIntervalMethodInfo          ,
#endif
    timeZoneFindInterval                    ,


-- ** getAbbreviation #method:getAbbreviation#

#if ENABLE_OVERLOADING
    TimeZoneGetAbbreviationMethodInfo       ,
#endif
    timeZoneGetAbbreviation                 ,


-- ** getIdentifier #method:getIdentifier#

#if ENABLE_OVERLOADING
    TimeZoneGetIdentifierMethodInfo         ,
#endif
    timeZoneGetIdentifier                   ,


-- ** getOffset #method:getOffset#

#if ENABLE_OVERLOADING
    TimeZoneGetOffsetMethodInfo             ,
#endif
    timeZoneGetOffset                       ,


-- ** isDst #method:isDst#

#if ENABLE_OVERLOADING
    TimeZoneIsDstMethodInfo                 ,
#endif
    timeZoneIsDst                           ,


-- ** new #method:new#

    timeZoneNew                             ,


-- ** newLocal #method:newLocal#

    timeZoneNewLocal                        ,


-- ** newOffset #method:newOffset#

    timeZoneNewOffset                       ,


-- ** newUtc #method:newUtc#

    timeZoneNewUtc                          ,


-- ** ref #method:ref#

#if ENABLE_OVERLOADING
    TimeZoneRefMethodInfo                   ,
#endif
    timeZoneRef                             ,


-- ** unref #method:unref#

#if ENABLE_OVERLOADING
    TimeZoneUnrefMethodInfo                 ,
#endif
    timeZoneUnref                           ,




    ) 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.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.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

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

-- | Memory-managed wrapper type.
newtype TimeZone = TimeZone (ManagedPtr TimeZone)
foreign import ccall "g_time_zone_get_type" c_g_time_zone_get_type :: 
    IO GType

instance BoxedObject TimeZone where
    boxedType :: TimeZone -> IO GType
boxedType _ = IO GType
c_g_time_zone_get_type

-- | A convenience alias for `Nothing` :: `Maybe` `TimeZone`.
noTimeZone :: Maybe TimeZone
noTimeZone :: Maybe TimeZone
noTimeZone = Maybe TimeZone
forall a. Maybe a
Nothing


#if ENABLE_OVERLOADING
instance O.HasAttributeList TimeZone
type instance O.AttributeList TimeZone = TimeZoneAttributeList
type TimeZoneAttributeList = ('[ ] :: [(Symbol, *)])
#endif

-- method TimeZone::new
-- method type : Constructor
-- Args : [Arg {argCName = "identifier", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a timezone identifier", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "TimeZone"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_time_zone_new" g_time_zone_new :: 
    CString ->                              -- identifier : TBasicType TUTF8
    IO (Ptr TimeZone)

{- |
Creates a 'GI.GLib.Structs.TimeZone.TimeZone' corresponding to /@identifier@/.

/@identifier@/ can either be an RFC3339\/ISO 8601 time offset or
something that would pass as a valid value for the @TZ@ environment
variable (including 'Nothing').

In Windows, /@identifier@/ can also be the unlocalized name of a time
zone for standard time, for example \"Pacific Standard Time\".

Valid RFC3339 time offsets are @\"Z\"@ (for UTC) or
@\"±hh:mm\"@.  ISO 8601 additionally specifies
@\"±hhmm\"@ and @\"±hh\"@.  Offsets are
time values to be added to Coordinated Universal Time (UTC) to get
the local time.

In UNIX, the @TZ@ environment variable typically corresponds
to the name of a file in the zoneinfo database, an absolute path to a file
somewhere else, or a string in
\"std offset [dst [offset],start[\/time],end[\/time]]\" (POSIX) format.
There  are  no spaces in the specification. The name of standard
and daylight savings time zone must be three or more alphabetic
characters. Offsets are time values to be added to local time to
get Coordinated Universal Time (UTC) and should be
@\"[±]hh[[:]mm[:ss]]\"@.  Dates are either
@\"Jn\"@ (Julian day with n between 1 and 365, leap
years not counted), @\"n\"@ (zero-based Julian day
with n between 0 and 365) or @\"Mm.w.d\"@ (day d
(0 \<= d \<= 6) of week w (1 \<= w \<= 5) of month m (1 \<= m \<= 12), day
0 is a Sunday).  Times are in local wall clock time, the default is
02:00:00.

In Windows, the \"tzn[+|–]hh[:mm[:ss]][dzn]\" format is used, but also
accepts POSIX format.  The Windows format uses US rules for all time
zones; daylight savings time is 60 minutes behind the standard time
with date and time of change taken from Pacific Standard Time.
Offsets are time values to be added to the local time to get
Coordinated Universal Time (UTC).

'GI.GLib.Structs.TimeZone.timeZoneNewLocal' calls this function with the value of the
@TZ@ environment variable. This function itself is independent of
the value of @TZ@, but if /@identifier@/ is 'Nothing' then @\/etc\/localtime@
will be consulted to discover the correct time zone on UNIX and the
registry will be consulted or @/GetTimeZoneInformation()/@ will be used
to get the local time zone on Windows.

If intervals are not available, only time zone rules from @TZ@
environment variable or other means, then they will be computed
from year 1900 to 2037.  If the maximum year for the rules is
available and it is greater than 2037, then it will followed
instead.

See
<http://tools.ietf.org/html/rfc3339#section-5.6 RFC3339 §5.6>
for a precise definition of valid RFC3339 time offsets
(the @time-offset@ expansion) and ISO 8601 for the
full list of valid time offsets.  See
<http://www.gnu.org/s/libc/manual/html_node/TZ-Variable.html The GNU C Library manual>
for an explanation of the possible
values of the @TZ@ environment variable. See
<http://msdn.microsoft.com/en-us/library/ms912391%28v=winembedded.11%29.aspx Microsoft Time Zone Index Values>
for the list of time zones on Windows.

You should release the return value by calling 'GI.GLib.Structs.TimeZone.timeZoneUnref'
when you are done with it.

/Since: 2.26/
-}
timeZoneNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Maybe (T.Text)
    {- ^ /@identifier@/: a timezone identifier -}
    -> m TimeZone
    {- ^ __Returns:__ the requested timezone -}
timeZoneNew :: Maybe Text -> m TimeZone
timeZoneNew identifier :: Maybe Text
identifier = IO TimeZone -> m TimeZone
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TimeZone -> m TimeZone) -> IO TimeZone -> m TimeZone
forall a b. (a -> b) -> a -> b
$ do
    Ptr CChar
maybeIdentifier <- case Maybe Text
identifier of
        Nothing -> Ptr CChar -> IO (Ptr CChar)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
forall a. Ptr a
nullPtr
        Just jIdentifier :: Text
jIdentifier -> do
            Ptr CChar
jIdentifier' <- Text -> IO (Ptr CChar)
textToCString Text
jIdentifier
            Ptr CChar -> IO (Ptr CChar)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
jIdentifier'
    Ptr TimeZone
result <- Ptr CChar -> IO (Ptr TimeZone)
g_time_zone_new Ptr CChar
maybeIdentifier
    Text -> Ptr TimeZone -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "timeZoneNew" Ptr TimeZone
result
    TimeZone
result' <- ((ManagedPtr TimeZone -> TimeZone) -> Ptr TimeZone -> IO TimeZone
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr TimeZone -> TimeZone
TimeZone) Ptr TimeZone
result
    Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
maybeIdentifier
    TimeZone -> IO TimeZone
forall (m :: * -> *) a. Monad m => a -> m a
return TimeZone
result'

#if ENABLE_OVERLOADING
#endif

-- method TimeZone::new_local
-- method type : Constructor
-- Args : []
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "TimeZone"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_time_zone_new_local" g_time_zone_new_local :: 
    IO (Ptr TimeZone)

{- |
Creates a 'GI.GLib.Structs.TimeZone.TimeZone' corresponding to local time.  The local time
zone may change between invocations to this function; for example,
if the system administrator changes it.

This is equivalent to calling 'GI.GLib.Structs.TimeZone.timeZoneNew' with the value of
the @TZ@ environment variable (including the possibility of 'Nothing').

You should release the return value by calling 'GI.GLib.Structs.TimeZone.timeZoneUnref'
when you are done with it.

/Since: 2.26/
-}
timeZoneNewLocal ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m TimeZone
    {- ^ __Returns:__ the local timezone -}
timeZoneNewLocal :: m TimeZone
timeZoneNewLocal  = IO TimeZone -> m TimeZone
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TimeZone -> m TimeZone) -> IO TimeZone -> m TimeZone
forall a b. (a -> b) -> a -> b
$ do
    Ptr TimeZone
result <- IO (Ptr TimeZone)
g_time_zone_new_local
    Text -> Ptr TimeZone -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "timeZoneNewLocal" Ptr TimeZone
result
    TimeZone
result' <- ((ManagedPtr TimeZone -> TimeZone) -> Ptr TimeZone -> IO TimeZone
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr TimeZone -> TimeZone
TimeZone) Ptr TimeZone
result
    TimeZone -> IO TimeZone
forall (m :: * -> *) a. Monad m => a -> m a
return TimeZone
result'

#if ENABLE_OVERLOADING
#endif

-- method TimeZone::new_offset
-- method type : Constructor
-- Args : [Arg {argCName = "seconds", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "offset to UTC, in seconds", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "TimeZone"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_time_zone_new_offset" g_time_zone_new_offset :: 
    Int32 ->                                -- seconds : TBasicType TInt32
    IO (Ptr TimeZone)

{- |
Creates a 'GI.GLib.Structs.TimeZone.TimeZone' corresponding to the given constant offset from UTC,
in seconds.

This is equivalent to calling 'GI.GLib.Structs.TimeZone.timeZoneNew' with a string in the form
@[+|-]hh[:mm[:ss]]@.

/Since: 2.58/
-}
timeZoneNewOffset ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Int32
    {- ^ /@seconds@/: offset to UTC, in seconds -}
    -> m TimeZone
    {- ^ __Returns:__ a timezone at the given offset from UTC -}
timeZoneNewOffset :: Int32 -> m TimeZone
timeZoneNewOffset seconds :: Int32
seconds = IO TimeZone -> m TimeZone
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TimeZone -> m TimeZone) -> IO TimeZone -> m TimeZone
forall a b. (a -> b) -> a -> b
$ do
    Ptr TimeZone
result <- Int32 -> IO (Ptr TimeZone)
g_time_zone_new_offset Int32
seconds
    Text -> Ptr TimeZone -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "timeZoneNewOffset" Ptr TimeZone
result
    TimeZone
result' <- ((ManagedPtr TimeZone -> TimeZone) -> Ptr TimeZone -> IO TimeZone
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr TimeZone -> TimeZone
TimeZone) Ptr TimeZone
result
    TimeZone -> IO TimeZone
forall (m :: * -> *) a. Monad m => a -> m a
return TimeZone
result'

#if ENABLE_OVERLOADING
#endif

-- method TimeZone::new_utc
-- method type : Constructor
-- Args : []
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "TimeZone"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_time_zone_new_utc" g_time_zone_new_utc :: 
    IO (Ptr TimeZone)

{- |
Creates a 'GI.GLib.Structs.TimeZone.TimeZone' corresponding to UTC.

This is equivalent to calling 'GI.GLib.Structs.TimeZone.timeZoneNew' with a value like
\"Z\", \"UTC\", \"+00\", etc.

You should release the return value by calling 'GI.GLib.Structs.TimeZone.timeZoneUnref'
when you are done with it.

/Since: 2.26/
-}
timeZoneNewUtc ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m TimeZone
    {- ^ __Returns:__ the universal timezone -}
timeZoneNewUtc :: m TimeZone
timeZoneNewUtc  = IO TimeZone -> m TimeZone
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TimeZone -> m TimeZone) -> IO TimeZone -> m TimeZone
forall a b. (a -> b) -> a -> b
$ do
    Ptr TimeZone
result <- IO (Ptr TimeZone)
g_time_zone_new_utc
    Text -> Ptr TimeZone -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "timeZoneNewUtc" Ptr TimeZone
result
    TimeZone
result' <- ((ManagedPtr TimeZone -> TimeZone) -> Ptr TimeZone -> IO TimeZone
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr TimeZone -> TimeZone
TimeZone) Ptr TimeZone
result
    TimeZone -> IO TimeZone
forall (m :: * -> *) a. Monad m => a -> m a
return TimeZone
result'

#if ENABLE_OVERLOADING
#endif

-- method TimeZone::adjust_time
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "tz", argType = TInterface (Name {namespace = "GLib", name = "TimeZone"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTimeZone", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "type", argType = TInterface (Name {namespace = "GLib", name = "TimeType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GTimeType of @time_", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "time_", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a number of seconds since January 1, 1970", 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 "g_time_zone_adjust_time" g_time_zone_adjust_time :: 
    Ptr TimeZone ->                         -- tz : TInterface (Name {namespace = "GLib", name = "TimeZone"})
    CUInt ->                                -- type : TInterface (Name {namespace = "GLib", name = "TimeType"})
    Int64 ->                                -- time_ : TBasicType TInt64
    IO Int32

{- |
Finds an interval within /@tz@/ that corresponds to the given /@time_@/,
possibly adjusting /@time_@/ if required to fit into an interval.
The meaning of /@time_@/ depends on /@type@/.

This function is similar to 'GI.GLib.Structs.TimeZone.timeZoneFindInterval', with the
difference that it always succeeds (by making the adjustments
described below).

In any of the cases where 'GI.GLib.Structs.TimeZone.timeZoneFindInterval' succeeds then
this function returns the same value, without modifying /@time_@/.

This function may, however, modify /@time_@/ in order to deal with
non-existent times.  If the non-existent local /@time_@/ of 02:30 were
requested on March 14th 2010 in Toronto then this function would
adjust /@time_@/ to be 03:00 and return the interval containing the
adjusted time.

/Since: 2.26/
-}
timeZoneAdjustTime ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    TimeZone
    {- ^ /@tz@/: a 'GI.GLib.Structs.TimeZone.TimeZone' -}
    -> GLib.Enums.TimeType
    {- ^ /@type@/: the 'GI.GLib.Enums.TimeType' of /@time_@/ -}
    -> Int64
    {- ^ /@time_@/: a pointer to a number of seconds since January 1, 1970 -}
    -> m Int32
    {- ^ __Returns:__ the interval containing /@time_@/, never -1 -}
timeZoneAdjustTime :: TimeZone -> TimeType -> Int64 -> m Int32
timeZoneAdjustTime tz :: TimeZone
tz type_ :: TimeType
type_ time_ :: Int64
time_ = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    Ptr TimeZone
tz' <- TimeZone -> IO (Ptr TimeZone)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr TimeZone
tz
    let type_' :: CUInt
type_' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt) -> (TimeType -> Int) -> TimeType -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TimeType -> Int
forall a. Enum a => a -> Int
fromEnum) TimeType
type_
    Int32
result <- Ptr TimeZone -> CUInt -> Int64 -> IO Int32
g_time_zone_adjust_time Ptr TimeZone
tz' CUInt
type_' Int64
time_
    TimeZone -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr TimeZone
tz
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
result

#if ENABLE_OVERLOADING
data TimeZoneAdjustTimeMethodInfo
instance (signature ~ (GLib.Enums.TimeType -> Int64 -> m Int32), MonadIO m) => O.MethodInfo TimeZoneAdjustTimeMethodInfo TimeZone signature where
    overloadedMethod _ = timeZoneAdjustTime

#endif

-- method TimeZone::find_interval
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "tz", argType = TInterface (Name {namespace = "GLib", name = "TimeZone"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTimeZone", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "type", argType = TInterface (Name {namespace = "GLib", name = "TimeType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GTimeType of @time_", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "time_", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a number of seconds since January 1, 1970", 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 "g_time_zone_find_interval" g_time_zone_find_interval :: 
    Ptr TimeZone ->                         -- tz : TInterface (Name {namespace = "GLib", name = "TimeZone"})
    CUInt ->                                -- type : TInterface (Name {namespace = "GLib", name = "TimeType"})
    Int64 ->                                -- time_ : TBasicType TInt64
    IO Int32

{- |
Finds an interval within /@tz@/ that corresponds to the given /@time_@/.
The meaning of /@time_@/ depends on /@type@/.

If /@type@/ is 'GI.GLib.Enums.TimeTypeUniversal' then this function will always
succeed (since universal time is monotonic and continuous).

Otherwise /@time_@/ is treated as local time.  The distinction between
'GI.GLib.Enums.TimeTypeStandard' and 'GI.GLib.Enums.TimeTypeDaylight' is ignored except in
the case that the given /@time_@/ is ambiguous.  In Toronto, for example,
01:30 on November 7th 2010 occurred twice (once inside of daylight
savings time and the next, an hour later, outside of daylight savings
time).  In this case, the different value of /@type@/ would result in a
different interval being returned.

It is still possible for this function to fail.  In Toronto, for
example, 02:00 on March 14th 2010 does not exist (due to the leap
forward to begin daylight savings time).  -1 is returned in that
case.

/Since: 2.26/
-}
timeZoneFindInterval ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    TimeZone
    {- ^ /@tz@/: a 'GI.GLib.Structs.TimeZone.TimeZone' -}
    -> GLib.Enums.TimeType
    {- ^ /@type@/: the 'GI.GLib.Enums.TimeType' of /@time_@/ -}
    -> Int64
    {- ^ /@time_@/: a number of seconds since January 1, 1970 -}
    -> m Int32
    {- ^ __Returns:__ the interval containing /@time_@/, or -1 in case of failure -}
timeZoneFindInterval :: TimeZone -> TimeType -> Int64 -> m Int32
timeZoneFindInterval tz :: TimeZone
tz type_ :: TimeType
type_ time_ :: Int64
time_ = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    Ptr TimeZone
tz' <- TimeZone -> IO (Ptr TimeZone)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr TimeZone
tz
    let type_' :: CUInt
type_' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt) -> (TimeType -> Int) -> TimeType -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TimeType -> Int
forall a. Enum a => a -> Int
fromEnum) TimeType
type_
    Int32
result <- Ptr TimeZone -> CUInt -> Int64 -> IO Int32
g_time_zone_find_interval Ptr TimeZone
tz' CUInt
type_' Int64
time_
    TimeZone -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr TimeZone
tz
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
result

#if ENABLE_OVERLOADING
data TimeZoneFindIntervalMethodInfo
instance (signature ~ (GLib.Enums.TimeType -> Int64 -> m Int32), MonadIO m) => O.MethodInfo TimeZoneFindIntervalMethodInfo TimeZone signature where
    overloadedMethod _ = timeZoneFindInterval

#endif

-- method TimeZone::get_abbreviation
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "tz", argType = TInterface (Name {namespace = "GLib", name = "TimeZone"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTimeZone", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "interval", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an interval within the timezone", 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 "g_time_zone_get_abbreviation" g_time_zone_get_abbreviation :: 
    Ptr TimeZone ->                         -- tz : TInterface (Name {namespace = "GLib", name = "TimeZone"})
    Int32 ->                                -- interval : TBasicType TInt
    IO CString

{- |
Determines the time zone abbreviation to be used during a particular
/@interval@/ of time in the time zone /@tz@/.

For example, in Toronto this is currently \"EST\" during the winter
months and \"EDT\" during the summer months when daylight savings time
is in effect.

/Since: 2.26/
-}
timeZoneGetAbbreviation ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    TimeZone
    {- ^ /@tz@/: a 'GI.GLib.Structs.TimeZone.TimeZone' -}
    -> Int32
    {- ^ /@interval@/: an interval within the timezone -}
    -> m T.Text
    {- ^ __Returns:__ the time zone abbreviation, which belongs to /@tz@/ -}
timeZoneGetAbbreviation :: TimeZone -> Int32 -> m Text
timeZoneGetAbbreviation tz :: TimeZone
tz interval :: Int32
interval = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    Ptr TimeZone
tz' <- TimeZone -> IO (Ptr TimeZone)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr TimeZone
tz
    Ptr CChar
result <- Ptr TimeZone -> Int32 -> IO (Ptr CChar)
g_time_zone_get_abbreviation Ptr TimeZone
tz' Int32
interval
    Text -> Ptr CChar -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "timeZoneGetAbbreviation" Ptr CChar
result
    Text
result' <- HasCallStack => Ptr CChar -> IO Text
Ptr CChar -> IO Text
cstringToText Ptr CChar
result
    TimeZone -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr TimeZone
tz
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'

#if ENABLE_OVERLOADING
data TimeZoneGetAbbreviationMethodInfo
instance (signature ~ (Int32 -> m T.Text), MonadIO m) => O.MethodInfo TimeZoneGetAbbreviationMethodInfo TimeZone signature where
    overloadedMethod _ = timeZoneGetAbbreviation

#endif

-- method TimeZone::get_identifier
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "tz", argType = TInterface (Name {namespace = "GLib", name = "TimeZone"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTimeZone", 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 "g_time_zone_get_identifier" g_time_zone_get_identifier :: 
    Ptr TimeZone ->                         -- tz : TInterface (Name {namespace = "GLib", name = "TimeZone"})
    IO CString

{- |
Get the identifier of this 'GI.GLib.Structs.TimeZone.TimeZone', as passed to 'GI.GLib.Structs.TimeZone.timeZoneNew'.
If the identifier passed at construction time was not recognised, @UTC@ will
be returned. If it was 'Nothing', the identifier of the local timezone at
construction time will be returned.

The identifier will be returned in the same format as provided at
construction time: if provided as a time offset, that will be returned by
this function.

/Since: 2.58/
-}
timeZoneGetIdentifier ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    TimeZone
    {- ^ /@tz@/: a 'GI.GLib.Structs.TimeZone.TimeZone' -}
    -> m T.Text
    {- ^ __Returns:__ identifier for this timezone -}
timeZoneGetIdentifier :: TimeZone -> m Text
timeZoneGetIdentifier tz :: TimeZone
tz = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    Ptr TimeZone
tz' <- TimeZone -> IO (Ptr TimeZone)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr TimeZone
tz
    Ptr CChar
result <- Ptr TimeZone -> IO (Ptr CChar)
g_time_zone_get_identifier Ptr TimeZone
tz'
    Text -> Ptr CChar -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "timeZoneGetIdentifier" Ptr CChar
result
    Text
result' <- HasCallStack => Ptr CChar -> IO Text
Ptr CChar -> IO Text
cstringToText Ptr CChar
result
    TimeZone -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr TimeZone
tz
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'

#if ENABLE_OVERLOADING
data TimeZoneGetIdentifierMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo TimeZoneGetIdentifierMethodInfo TimeZone signature where
    overloadedMethod _ = timeZoneGetIdentifier

#endif

-- method TimeZone::get_offset
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "tz", argType = TInterface (Name {namespace = "GLib", name = "TimeZone"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTimeZone", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "interval", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an interval within the timezone", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt32)
-- throws : False
-- Skip return : False

foreign import ccall "g_time_zone_get_offset" g_time_zone_get_offset :: 
    Ptr TimeZone ->                         -- tz : TInterface (Name {namespace = "GLib", name = "TimeZone"})
    Int32 ->                                -- interval : TBasicType TInt
    IO Int32

{- |
Determines the offset to UTC in effect during a particular /@interval@/
of time in the time zone /@tz@/.

The offset is the number of seconds that you add to UTC time to
arrive at local time for /@tz@/ (ie: negative numbers for time zones
west of GMT, positive numbers for east).

/Since: 2.26/
-}
timeZoneGetOffset ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    TimeZone
    {- ^ /@tz@/: a 'GI.GLib.Structs.TimeZone.TimeZone' -}
    -> Int32
    {- ^ /@interval@/: an interval within the timezone -}
    -> m Int32
    {- ^ __Returns:__ the number of seconds that should be added to UTC to get the
         local time in /@tz@/ -}
timeZoneGetOffset :: TimeZone -> Int32 -> m Int32
timeZoneGetOffset tz :: TimeZone
tz interval :: Int32
interval = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    Ptr TimeZone
tz' <- TimeZone -> IO (Ptr TimeZone)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr TimeZone
tz
    Int32
result <- Ptr TimeZone -> Int32 -> IO Int32
g_time_zone_get_offset Ptr TimeZone
tz' Int32
interval
    TimeZone -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr TimeZone
tz
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
result

#if ENABLE_OVERLOADING
data TimeZoneGetOffsetMethodInfo
instance (signature ~ (Int32 -> m Int32), MonadIO m) => O.MethodInfo TimeZoneGetOffsetMethodInfo TimeZone signature where
    overloadedMethod _ = timeZoneGetOffset

#endif

-- method TimeZone::is_dst
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "tz", argType = TInterface (Name {namespace = "GLib", name = "TimeZone"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTimeZone", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "interval", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an interval within the timezone", 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 "g_time_zone_is_dst" g_time_zone_is_dst :: 
    Ptr TimeZone ->                         -- tz : TInterface (Name {namespace = "GLib", name = "TimeZone"})
    Int32 ->                                -- interval : TBasicType TInt
    IO CInt

{- |
Determines if daylight savings time is in effect during a particular
/@interval@/ of time in the time zone /@tz@/.

/Since: 2.26/
-}
timeZoneIsDst ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    TimeZone
    {- ^ /@tz@/: a 'GI.GLib.Structs.TimeZone.TimeZone' -}
    -> Int32
    {- ^ /@interval@/: an interval within the timezone -}
    -> m Bool
    {- ^ __Returns:__ 'True' if daylight savings time is in effect -}
timeZoneIsDst :: TimeZone -> Int32 -> m Bool
timeZoneIsDst tz :: TimeZone
tz interval :: Int32
interval = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr TimeZone
tz' <- TimeZone -> IO (Ptr TimeZone)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr TimeZone
tz
    CInt
result <- Ptr TimeZone -> Int32 -> IO CInt
g_time_zone_is_dst Ptr TimeZone
tz' Int32
interval
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    TimeZone -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr TimeZone
tz
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if ENABLE_OVERLOADING
data TimeZoneIsDstMethodInfo
instance (signature ~ (Int32 -> m Bool), MonadIO m) => O.MethodInfo TimeZoneIsDstMethodInfo TimeZone signature where
    overloadedMethod _ = timeZoneIsDst

#endif

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

foreign import ccall "g_time_zone_ref" g_time_zone_ref :: 
    Ptr TimeZone ->                         -- tz : TInterface (Name {namespace = "GLib", name = "TimeZone"})
    IO (Ptr TimeZone)

{- |
Increases the reference count on /@tz@/.

/Since: 2.26/
-}
timeZoneRef ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    TimeZone
    {- ^ /@tz@/: a 'GI.GLib.Structs.TimeZone.TimeZone' -}
    -> m TimeZone
    {- ^ __Returns:__ a new reference to /@tz@/. -}
timeZoneRef :: TimeZone -> m TimeZone
timeZoneRef tz :: TimeZone
tz = IO TimeZone -> m TimeZone
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TimeZone -> m TimeZone) -> IO TimeZone -> m TimeZone
forall a b. (a -> b) -> a -> b
$ do
    Ptr TimeZone
tz' <- TimeZone -> IO (Ptr TimeZone)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr TimeZone
tz
    Ptr TimeZone
result <- Ptr TimeZone -> IO (Ptr TimeZone)
g_time_zone_ref Ptr TimeZone
tz'
    Text -> Ptr TimeZone -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "timeZoneRef" Ptr TimeZone
result
    TimeZone
result' <- ((ManagedPtr TimeZone -> TimeZone) -> Ptr TimeZone -> IO TimeZone
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr TimeZone -> TimeZone
TimeZone) Ptr TimeZone
result
    TimeZone -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr TimeZone
tz
    TimeZone -> IO TimeZone
forall (m :: * -> *) a. Monad m => a -> m a
return TimeZone
result'

#if ENABLE_OVERLOADING
data TimeZoneRefMethodInfo
instance (signature ~ (m TimeZone), MonadIO m) => O.MethodInfo TimeZoneRefMethodInfo TimeZone signature where
    overloadedMethod _ = timeZoneRef

#endif

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

foreign import ccall "g_time_zone_unref" g_time_zone_unref :: 
    Ptr TimeZone ->                         -- tz : TInterface (Name {namespace = "GLib", name = "TimeZone"})
    IO ()

{- |
Decreases the reference count on /@tz@/.

/Since: 2.26/
-}
timeZoneUnref ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    TimeZone
    {- ^ /@tz@/: a 'GI.GLib.Structs.TimeZone.TimeZone' -}
    -> m ()
timeZoneUnref :: TimeZone -> m ()
timeZoneUnref tz :: TimeZone
tz = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr TimeZone
tz' <- TimeZone -> IO (Ptr TimeZone)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr TimeZone
tz
    Ptr TimeZone -> IO ()
g_time_zone_unref Ptr TimeZone
tz'
    TimeZone -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr TimeZone
tz
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if ENABLE_OVERLOADING
data TimeZoneUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo TimeZoneUnrefMethodInfo TimeZone signature where
    overloadedMethod _ = timeZoneUnref

#endif

#if ENABLE_OVERLOADING
type family ResolveTimeZoneMethod (t :: Symbol) (o :: *) :: * where
    ResolveTimeZoneMethod "adjustTime" o = TimeZoneAdjustTimeMethodInfo
    ResolveTimeZoneMethod "findInterval" o = TimeZoneFindIntervalMethodInfo
    ResolveTimeZoneMethod "isDst" o = TimeZoneIsDstMethodInfo
    ResolveTimeZoneMethod "ref" o = TimeZoneRefMethodInfo
    ResolveTimeZoneMethod "unref" o = TimeZoneUnrefMethodInfo
    ResolveTimeZoneMethod "getAbbreviation" o = TimeZoneGetAbbreviationMethodInfo
    ResolveTimeZoneMethod "getIdentifier" o = TimeZoneGetIdentifierMethodInfo
    ResolveTimeZoneMethod "getOffset" o = TimeZoneGetOffsetMethodInfo
    ResolveTimeZoneMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveTimeZoneMethod t TimeZone, O.MethodInfo info TimeZone p) => O.IsLabelProxy t (TimeZone -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveTimeZoneMethod t TimeZone, O.MethodInfo info TimeZone p) => O.IsLabel t (TimeZone -> 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

#endif