{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc) @GDateTime@ is an opaque structure whose members cannot be accessed directly. /Since: 2.26/ -} #define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \ && !defined(__HADDOCK_VERSION__)) module GI.GLib.Structs.DateTime ( -- * Exported types DateTime(..) , noDateTime , -- * Methods -- ** add #method:add# #if ENABLE_OVERLOADING DateTimeAddMethodInfo , #endif dateTimeAdd , -- ** addDays #method:addDays# #if ENABLE_OVERLOADING DateTimeAddDaysMethodInfo , #endif dateTimeAddDays , -- ** addFull #method:addFull# #if ENABLE_OVERLOADING DateTimeAddFullMethodInfo , #endif dateTimeAddFull , -- ** addHours #method:addHours# #if ENABLE_OVERLOADING DateTimeAddHoursMethodInfo , #endif dateTimeAddHours , -- ** addMinutes #method:addMinutes# #if ENABLE_OVERLOADING DateTimeAddMinutesMethodInfo , #endif dateTimeAddMinutes , -- ** addMonths #method:addMonths# #if ENABLE_OVERLOADING DateTimeAddMonthsMethodInfo , #endif dateTimeAddMonths , -- ** addSeconds #method:addSeconds# #if ENABLE_OVERLOADING DateTimeAddSecondsMethodInfo , #endif dateTimeAddSeconds , -- ** addWeeks #method:addWeeks# #if ENABLE_OVERLOADING DateTimeAddWeeksMethodInfo , #endif dateTimeAddWeeks , -- ** addYears #method:addYears# #if ENABLE_OVERLOADING DateTimeAddYearsMethodInfo , #endif dateTimeAddYears , -- ** compare #method:compare# dateTimeCompare , -- ** difference #method:difference# #if ENABLE_OVERLOADING DateTimeDifferenceMethodInfo , #endif dateTimeDifference , -- ** equal #method:equal# dateTimeEqual , -- ** format #method:format# #if ENABLE_OVERLOADING DateTimeFormatMethodInfo , #endif dateTimeFormat , -- ** getDayOfMonth #method:getDayOfMonth# #if ENABLE_OVERLOADING DateTimeGetDayOfMonthMethodInfo , #endif dateTimeGetDayOfMonth , -- ** getDayOfWeek #method:getDayOfWeek# #if ENABLE_OVERLOADING DateTimeGetDayOfWeekMethodInfo , #endif dateTimeGetDayOfWeek , -- ** getDayOfYear #method:getDayOfYear# #if ENABLE_OVERLOADING DateTimeGetDayOfYearMethodInfo , #endif dateTimeGetDayOfYear , -- ** getHour #method:getHour# #if ENABLE_OVERLOADING DateTimeGetHourMethodInfo , #endif dateTimeGetHour , -- ** getMicrosecond #method:getMicrosecond# #if ENABLE_OVERLOADING DateTimeGetMicrosecondMethodInfo , #endif dateTimeGetMicrosecond , -- ** getMinute #method:getMinute# #if ENABLE_OVERLOADING DateTimeGetMinuteMethodInfo , #endif dateTimeGetMinute , -- ** getMonth #method:getMonth# #if ENABLE_OVERLOADING DateTimeGetMonthMethodInfo , #endif dateTimeGetMonth , -- ** getSecond #method:getSecond# #if ENABLE_OVERLOADING DateTimeGetSecondMethodInfo , #endif dateTimeGetSecond , -- ** getSeconds #method:getSeconds# #if ENABLE_OVERLOADING DateTimeGetSecondsMethodInfo , #endif dateTimeGetSeconds , -- ** getTimezone #method:getTimezone# #if ENABLE_OVERLOADING DateTimeGetTimezoneMethodInfo , #endif dateTimeGetTimezone , -- ** getTimezoneAbbreviation #method:getTimezoneAbbreviation# #if ENABLE_OVERLOADING DateTimeGetTimezoneAbbreviationMethodInfo, #endif dateTimeGetTimezoneAbbreviation , -- ** getUtcOffset #method:getUtcOffset# #if ENABLE_OVERLOADING DateTimeGetUtcOffsetMethodInfo , #endif dateTimeGetUtcOffset , -- ** getWeekNumberingYear #method:getWeekNumberingYear# #if ENABLE_OVERLOADING DateTimeGetWeekNumberingYearMethodInfo , #endif dateTimeGetWeekNumberingYear , -- ** getWeekOfYear #method:getWeekOfYear# #if ENABLE_OVERLOADING DateTimeGetWeekOfYearMethodInfo , #endif dateTimeGetWeekOfYear , -- ** getYear #method:getYear# #if ENABLE_OVERLOADING DateTimeGetYearMethodInfo , #endif dateTimeGetYear , -- ** getYmd #method:getYmd# #if ENABLE_OVERLOADING DateTimeGetYmdMethodInfo , #endif dateTimeGetYmd , -- ** hash #method:hash# dateTimeHash , -- ** isDaylightSavings #method:isDaylightSavings# #if ENABLE_OVERLOADING DateTimeIsDaylightSavingsMethodInfo , #endif dateTimeIsDaylightSavings , -- ** new #method:new# dateTimeNew , -- ** newFromIso8601 #method:newFromIso8601# dateTimeNewFromIso8601 , -- ** newFromTimevalLocal #method:newFromTimevalLocal# dateTimeNewFromTimevalLocal , -- ** newFromTimevalUtc #method:newFromTimevalUtc# dateTimeNewFromTimevalUtc , -- ** newFromUnixLocal #method:newFromUnixLocal# dateTimeNewFromUnixLocal , -- ** newFromUnixUtc #method:newFromUnixUtc# dateTimeNewFromUnixUtc , -- ** newLocal #method:newLocal# dateTimeNewLocal , -- ** newNow #method:newNow# dateTimeNewNow , -- ** newNowLocal #method:newNowLocal# dateTimeNewNowLocal , -- ** newNowUtc #method:newNowUtc# dateTimeNewNowUtc , -- ** newUtc #method:newUtc# dateTimeNewUtc , -- ** ref #method:ref# #if ENABLE_OVERLOADING DateTimeRefMethodInfo , #endif dateTimeRef , -- ** toLocal #method:toLocal# #if ENABLE_OVERLOADING DateTimeToLocalMethodInfo , #endif dateTimeToLocal , -- ** toTimeval #method:toTimeval# #if ENABLE_OVERLOADING DateTimeToTimevalMethodInfo , #endif dateTimeToTimeval , -- ** toTimezone #method:toTimezone# #if ENABLE_OVERLOADING DateTimeToTimezoneMethodInfo , #endif dateTimeToTimezone , -- ** toUnix #method:toUnix# #if ENABLE_OVERLOADING DateTimeToUnixMethodInfo , #endif dateTimeToUnix , -- ** toUtc #method:toUtc# #if ENABLE_OVERLOADING DateTimeToUtcMethodInfo , #endif dateTimeToUtc , -- ** unref #method:unref# #if ENABLE_OVERLOADING DateTimeUnrefMethodInfo , #endif dateTimeUnref , ) 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 {-# SOURCE #-} qualified GI.GLib.Structs.TimeVal as GLib.TimeVal import {-# SOURCE #-} qualified GI.GLib.Structs.TimeZone as GLib.TimeZone -- | Memory-managed wrapper type. newtype DateTime = DateTime (ManagedPtr DateTime) foreign import ccall "g_date_time_get_type" c_g_date_time_get_type :: IO GType instance BoxedObject DateTime where boxedType _ = c_g_date_time_get_type -- | A convenience alias for `Nothing` :: `Maybe` `DateTime`. noDateTime :: Maybe DateTime noDateTime = Nothing #if ENABLE_OVERLOADING instance O.HasAttributeList DateTime type instance O.AttributeList DateTime = DateTimeAttributeList type DateTimeAttributeList = ('[ ] :: [(Symbol, *)]) #endif -- method DateTime::new -- method type : Constructor -- 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 = "year", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the year component of the date", 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 component of the date", 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 component of the date", 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 component of the date", 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 component of the date", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "seconds", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of seconds past the minute", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GLib", name = "DateTime"})) -- throws : False -- Skip return : False foreign import ccall "g_date_time_new" g_date_time_new :: Ptr GLib.TimeZone.TimeZone -> -- tz : TInterface (Name {namespace = "GLib", name = "TimeZone"}) Int32 -> -- year : TBasicType TInt Int32 -> -- month : TBasicType TInt Int32 -> -- day : TBasicType TInt Int32 -> -- hour : TBasicType TInt Int32 -> -- minute : TBasicType TInt CDouble -> -- seconds : TBasicType TDouble IO (Ptr DateTime) {- | Creates a new 'GI.GLib.Structs.DateTime.DateTime' corresponding to the given date and time in the time zone /@tz@/. The /@year@/ must be between 1 and 9999, /@month@/ between 1 and 12 and /@day@/ between 1 and 28, 29, 30 or 31 depending on the month and the year. /@hour@/ must be between 0 and 23 and /@minute@/ must be between 0 and 59. /@seconds@/ must be at least 0.0 and must be strictly less than 60.0. It will be rounded down to the nearest microsecond. If the given time is not representable in the given time zone (for example, 02:30 on March 14th 2010 in Toronto, due to daylight savings time) then the time will be rounded up to the nearest existing time (in this case, 03:00). If this matters to you then you should verify the return value for containing the same as the numbers you gave. In the case that the given time is ambiguous in the given time zone (for example, 01:30 on November 7th 2010 in Toronto, due to daylight savings time) then the time falling within standard (ie: non-daylight) time is taken. It not considered a programmer error for the values to this function to be out of range, but in the case that they are, the function will return 'Nothing'. You should release the return value by calling 'GI.GLib.Structs.DateTime.dateTimeUnref' when you are done with it. /Since: 2.26/ -} dateTimeNew :: (B.CallStack.HasCallStack, MonadIO m) => GLib.TimeZone.TimeZone {- ^ /@tz@/: a 'GI.GLib.Structs.TimeZone.TimeZone' -} -> Int32 {- ^ /@year@/: the year component of the date -} -> Int32 {- ^ /@month@/: the month component of the date -} -> Int32 {- ^ /@day@/: the day component of the date -} -> Int32 {- ^ /@hour@/: the hour component of the date -} -> Int32 {- ^ /@minute@/: the minute component of the date -} -> Double {- ^ /@seconds@/: the number of seconds past the minute -} -> m DateTime {- ^ __Returns:__ a new 'GI.GLib.Structs.DateTime.DateTime', or 'Nothing' -} dateTimeNew tz year month day hour minute seconds = liftIO $ do tz' <- unsafeManagedPtrGetPtr tz let seconds' = realToFrac seconds result <- g_date_time_new tz' year month day hour minute seconds' checkUnexpectedReturnNULL "dateTimeNew" result result' <- (wrapBoxed DateTime) result touchManagedPtr tz return result' #if ENABLE_OVERLOADING #endif -- method DateTime::new_from_iso8601 -- method type : Constructor -- Args : [Arg {argCName = "text", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an ISO 8601 formatted time string.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "default_tz", argType = TInterface (Name {namespace = "GLib", name = "TimeZone"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GTimeZone to use if the text doesn't contain a\n timezone, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GLib", name = "DateTime"})) -- throws : False -- Skip return : False foreign import ccall "g_date_time_new_from_iso8601" g_date_time_new_from_iso8601 :: CString -> -- text : TBasicType TUTF8 Ptr GLib.TimeZone.TimeZone -> -- default_tz : TInterface (Name {namespace = "GLib", name = "TimeZone"}) IO (Ptr DateTime) {- | Creates a 'GI.GLib.Structs.DateTime.DateTime' corresponding to the given /@text@/. ISO 8601 strings of the form \\\