gi-glib-2.0.12: GLib bindings

CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria (garetxe@gmail.com)
Safe HaskellNone
LanguageHaskell2010

GI.GLib.Structs.DateTime

Contents

Description

GDateTime is an opaque structure whose members cannot be accessed directly.

Synopsis

Exported types

newtype DateTime #

Constructors

DateTime (ManagedPtr DateTime) 

Instances

BoxedObject DateTime # 

Methods

boxedType :: DateTime -> IO GType #

((~) * info (ResolveDateTimeMethod t DateTime), MethodInfo * info DateTime p) => IsLabel t (DateTime -> p) # 

Methods

fromLabel :: Proxy# Symbol t -> DateTime -> p #

((~) * info (ResolveDateTimeMethod t DateTime), MethodInfo * info DateTime p) => IsLabelProxy t (DateTime -> p) # 

Methods

fromLabelProxy :: Proxy Symbol t -> DateTime -> p #

HasAttributeList * DateTime # 
((~) * signature (m ()), MonadIO m) => MethodInfo * DateTimeUnrefMethodInfo DateTime signature # 
((~) * signature (m DateTime), MonadIO m) => MethodInfo * DateTimeToUtcMethodInfo DateTime signature # 
((~) * signature (m Int64), MonadIO m) => MethodInfo * DateTimeToUnixMethodInfo DateTime signature # 
((~) * signature (TimeZone -> m DateTime), MonadIO m) => MethodInfo * DateTimeToTimezoneMethodInfo DateTime signature # 
((~) * signature (TimeVal -> m Bool), MonadIO m) => MethodInfo * DateTimeToTimevalMethodInfo DateTime signature # 
((~) * signature (m DateTime), MonadIO m) => MethodInfo * DateTimeToLocalMethodInfo DateTime signature # 
((~) * signature (m DateTime), MonadIO m) => MethodInfo * DateTimeRefMethodInfo DateTime signature # 
((~) * signature (m Bool), MonadIO m) => MethodInfo * DateTimeIsDaylightSavingsMethodInfo DateTime signature # 
((~) * signature (m (Int32, Int32, Int32)), MonadIO m) => MethodInfo * DateTimeGetYmdMethodInfo DateTime signature # 
((~) * signature (m Int32), MonadIO m) => MethodInfo * DateTimeGetYearMethodInfo DateTime signature # 
((~) * signature (m Int32), MonadIO m) => MethodInfo * DateTimeGetWeekOfYearMethodInfo DateTime signature # 
((~) * signature (m Int32), MonadIO m) => MethodInfo * DateTimeGetWeekNumberingYearMethodInfo DateTime signature # 
((~) * signature (m Int64), MonadIO m) => MethodInfo * DateTimeGetUtcOffsetMethodInfo DateTime signature # 
((~) * signature (m Text), MonadIO m) => MethodInfo * DateTimeGetTimezoneAbbreviationMethodInfo DateTime signature # 
((~) * signature (m Double), MonadIO m) => MethodInfo * DateTimeGetSecondsMethodInfo DateTime signature # 
((~) * signature (m Int32), MonadIO m) => MethodInfo * DateTimeGetSecondMethodInfo DateTime signature # 
((~) * signature (m Int32), MonadIO m) => MethodInfo * DateTimeGetMonthMethodInfo DateTime signature # 
((~) * signature (m Int32), MonadIO m) => MethodInfo * DateTimeGetMinuteMethodInfo DateTime signature # 
((~) * signature (m Int32), MonadIO m) => MethodInfo * DateTimeGetMicrosecondMethodInfo DateTime signature # 
((~) * signature (m Int32), MonadIO m) => MethodInfo * DateTimeGetHourMethodInfo DateTime signature # 
((~) * signature (m Int32), MonadIO m) => MethodInfo * DateTimeGetDayOfYearMethodInfo DateTime signature # 
((~) * signature (m Int32), MonadIO m) => MethodInfo * DateTimeGetDayOfWeekMethodInfo DateTime signature # 
((~) * signature (m Int32), MonadIO m) => MethodInfo * DateTimeGetDayOfMonthMethodInfo DateTime signature # 
((~) * signature (Text -> m Text), MonadIO m) => MethodInfo * DateTimeFormatMethodInfo DateTime signature # 
((~) * signature (DateTime -> m Int64), MonadIO m) => MethodInfo * DateTimeDifferenceMethodInfo DateTime signature # 
((~) * signature (Int32 -> m DateTime), MonadIO m) => MethodInfo * DateTimeAddYearsMethodInfo DateTime signature # 
((~) * signature (Int32 -> m DateTime), MonadIO m) => MethodInfo * DateTimeAddWeeksMethodInfo DateTime signature # 
((~) * signature (Double -> m DateTime), MonadIO m) => MethodInfo * DateTimeAddSecondsMethodInfo DateTime signature # 
((~) * signature (Int32 -> m DateTime), MonadIO m) => MethodInfo * DateTimeAddMonthsMethodInfo DateTime signature # 
((~) * signature (Int32 -> m DateTime), MonadIO m) => MethodInfo * DateTimeAddMinutesMethodInfo DateTime signature # 
((~) * signature (Int32 -> m DateTime), MonadIO m) => MethodInfo * DateTimeAddHoursMethodInfo DateTime signature # 
((~) * signature (Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Double -> m DateTime), MonadIO m) => MethodInfo * DateTimeAddFullMethodInfo DateTime signature # 
((~) * signature (Int32 -> m DateTime), MonadIO m) => MethodInfo * DateTimeAddDaysMethodInfo DateTime signature # 
((~) * signature (Int64 -> m DateTime), MonadIO m) => MethodInfo * DateTimeAddMethodInfo DateTime signature # 
type AttributeList DateTime # 

Methods

add

data DateTimeAddMethodInfo #

Instances

((~) * signature (Int64 -> m DateTime), MonadIO m) => MethodInfo * DateTimeAddMethodInfo DateTime signature # 

dateTimeAdd #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

datetime: a DateTime

-> Int64

timespan: a GTimeSpan

-> m DateTime

Returns: the newly created DateTime which should be freed with dateTimeUnref.

Creates a copy of datetime and adds the specified timespan to the copy.

Since: 2.26

addDays

dateTimeAddDays #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

datetime: a DateTime

-> Int32

days: the number of days

-> m DateTime

Returns: the newly created DateTime which should be freed with dateTimeUnref.

Creates a copy of datetime and adds the specified number of days to the copy. Add negative values to subtract days.

Since: 2.26

addFull

dateTimeAddFull #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

datetime: a DateTime

-> Int32

years: the number of years to add

-> Int32

months: the number of months to add

-> Int32

days: the number of days to add

-> Int32

hours: the number of hours to add

-> Int32

minutes: the number of minutes to add

-> Double

seconds: the number of seconds to add

-> m DateTime

Returns: the newly created DateTime that should be freed with dateTimeUnref.

Creates a new DateTime adding the specified values to the current date and time in datetime. Add negative values to subtract.

Since: 2.26

addHours

dateTimeAddHours #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

datetime: a DateTime

-> Int32

hours: the number of hours to add

-> m DateTime

Returns: the newly created DateTime which should be freed with dateTimeUnref.

Creates a copy of datetime and adds the specified number of hours. Add negative values to subtract hours.

Since: 2.26

addMinutes

dateTimeAddMinutes #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

datetime: a DateTime

-> Int32

minutes: the number of minutes to add

-> m DateTime

Returns: the newly created DateTime which should be freed with dateTimeUnref.

Creates a copy of datetime adding the specified number of minutes. Add negative values to subtract minutes.

Since: 2.26

addMonths

dateTimeAddMonths #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

datetime: a DateTime

-> Int32

months: the number of months

-> m DateTime

Returns: the newly created DateTime which should be freed with dateTimeUnref.

Creates a copy of datetime and adds the specified number of months to the copy. Add negative values to subtract months.

Since: 2.26

addSeconds

dateTimeAddSeconds #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

datetime: a DateTime

-> Double

seconds: the number of seconds to add

-> m DateTime

Returns: the newly created DateTime which should be freed with dateTimeUnref.

Creates a copy of datetime and adds the specified number of seconds. Add negative values to subtract seconds.

Since: 2.26

addWeeks

dateTimeAddWeeks #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

datetime: a DateTime

-> Int32

weeks: the number of weeks

-> m DateTime

Returns: the newly created DateTime which should be freed with dateTimeUnref.

Creates a copy of datetime and adds the specified number of weeks to the copy. Add negative values to subtract weeks.

Since: 2.26

addYears

dateTimeAddYears #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

datetime: a DateTime

-> Int32

years: the number of years

-> m DateTime

Returns: the newly created DateTime which should be freed with dateTimeUnref.

Creates a copy of datetime and adds the specified number of years to the copy. Add negative values to subtract years.

Since: 2.26

compare

dateTimeCompare #

Arguments

:: (HasCallStack, MonadIO m) 
=> Ptr ()

dt1: first DateTime to compare

-> Ptr ()

dt2: second DateTime to compare

-> m Int32

Returns: -1, 0 or 1 if dt1 is less than, equal to or greater than dt2.

A comparison function for GDateTimes that is suitable as a CompareFunc. Both GDateTimes must be non-Nothing.

Since: 2.26

difference

dateTimeDifference #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

end: a DateTime

-> DateTime

begin: a DateTime

-> m Int64

Returns: the difference between the two DateTime, as a time span expressed in microseconds.

Calculates the difference in time between end and begin. The GTimeSpan that is returned is effectively end - begin (ie: positive if the first parameter is larger).

Since: 2.26

equal

dateTimeEqual #

Arguments

:: (HasCallStack, MonadIO m) 
=> Ptr ()

dt1: a DateTime

-> Ptr ()

dt2: a DateTime

-> m Bool

Returns: True if dt1 and dt2 are equal

Checks to see if dt1 and dt2 are equal.

Equal here means that they represent the same moment after converting them to the same time zone.

Since: 2.26

format

data DateTimeFormatMethodInfo #

Instances

((~) * signature (Text -> m Text), MonadIO m) => MethodInfo * DateTimeFormatMethodInfo DateTime signature # 

dateTimeFormat #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

datetime: A DateTime

-> Text

format: a valid UTF-8 string, containing the format for the DateTime

-> m Text

Returns: a newly allocated string formatted to the requested format or Nothing in the case that there was an error. The string should be freed with free.

Creates a newly allocated string representing the requested format.

The format strings understood by this function are a subset of the strftime() format language as specified by C99. The %D, %U and %W conversions are not supported, nor is the 'E' modifier. The GNU extensions %k, %l, %s and %P are supported, however, as are the '0', '_' and '-' modifiers.

In contrast to strftime(), this function always produces a UTF-8 string, regardless of the current locale. Note that the rendering of many formats is locale-dependent and may not match the strftime() output exactly.

The following format specifiers are supported:

  • %a: the abbreviated weekday name according to the current locale
  • %A: the full weekday name according to the current locale
  • %b: the abbreviated month name according to the current locale
  • %B: the full month name according to the current locale
  • %c: the preferred date and time representation for the current locale
  • %C: the century number (year/100) as a 2-digit integer (00-99)
  • %d: the day of the month as a decimal number (range 01 to 31)
  • %e: the day of the month as a decimal number (range 1 to 31)
  • %F: equivalent to %Y-%m-%d (the ISO 8601 date format)
  • %g: the last two digits of the ISO 8601 week-based year as a decimal number (00-99). This works well with %V and %u.
  • %G: the ISO 8601 week-based year as a decimal number. This works well with %V and %u.
  • %h: equivalent to %b
  • %H: the hour as a decimal number using a 24-hour clock (range 00 to 23)
  • %I: the hour as a decimal number using a 12-hour clock (range 01 to 12)
  • %j: the day of the year as a decimal number (range 001 to 366)
  • %k: the hour (24-hour clock) as a decimal number (range 0 to 23); single digits are preceded by a blank
  • %l: the hour (12-hour clock) as a decimal number (range 1 to 12); single digits are preceded by a blank
  • %m: the month as a decimal number (range 01 to 12)
  • %M: the minute as a decimal number (range 00 to 59)
  • %p: either "AM" or "PM" according to the given time value, or the corresponding strings for the current locale. Noon is treated as "PM" and midnight as "AM".
  • %P: like %p but lowercase: "am" or "pm" or a corresponding string for the current locale
  • %r: the time in a.m. or p.m. notation
  • %R: the time in 24-hour notation (%H:%M)
  • %s: the number of seconds since the Epoch, that is, since 1970-01-01 00:00:00 UTC
  • %S: the second as a decimal number (range 00 to 60)
  • %t: a tab character
  • %T: the time in 24-hour notation with seconds (%H:%M:%S)
  • %u: the ISO 8601 standard day of the week as a decimal, range 1 to 7, Monday being 1. This works well with %G and %V.
  • %V: the ISO 8601 standard week number of the current year as a decimal number, range 01 to 53, where week 1 is the first week that has at least 4 days in the new year. See dateTimeGetWeekOfYear. This works well with %G and %u.
  • %w: the day of the week as a decimal, range 0 to 6, Sunday being 0. This is not the ISO 8601 standard format -- use %u instead.
  • %x: the preferred date representation for the current locale without the time
  • %X: the preferred time representation for the current locale without the date
  • %y: the year as a decimal number without the century
  • %Y: the year as a decimal number including the century
  • %z: the time zone as an offset from UTC (+hhmm)
  • %:z: the time zone as an offset from UTC (+hh:mm). This is a gnulib strftime() extension. Since: 2.38
  • %::z: the time zone as an offset from UTC (+hh:mm:ss). This is a gnulib strftime() extension. Since: 2.38
  • %:::z: the time zone as an offset from UTC, with : to necessary precision (e.g., -04, +05:30). This is a gnulib strftime() extension. Since: 2.38
  • %Z: the time zone or name or abbreviation
  • %%: a literal % character

Some conversion specifications can be modified by preceding the conversion specifier by one or more modifier characters. The following modifiers are supported for many of the numeric conversions:

  • O: Use alternative numeric symbols, if the current locale supports those.
  • _: Pad a numeric result with spaces. This overrides the default padding for the specifier.
  • -: Do not pad a numeric result. This overrides the default padding for the specifier.
  • 0: Pad a numeric result with zeros. This overrides the default padding for the specifier.

Since: 2.26

getDayOfMonth

dateTimeGetDayOfMonth #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

datetime: a DateTime

-> m Int32

Returns: the day of the month

Retrieves the day of the month represented by datetime in the gregorian calendar.

Since: 2.26

getDayOfWeek

dateTimeGetDayOfWeek #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

datetime: a DateTime

-> m Int32

Returns: the day of the week

Retrieves the ISO 8601 day of the week on which datetime falls (1 is Monday, 2 is Tuesday... 7 is Sunday).

Since: 2.26

getDayOfYear

dateTimeGetDayOfYear #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

datetime: a DateTime

-> m Int32

Returns: the day of the year

Retrieves the day of the year represented by datetime in the Gregorian calendar.

Since: 2.26

getHour

dateTimeGetHour #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

datetime: a DateTime

-> m Int32

Returns: the hour of the day

Retrieves the hour of the day represented by datetime

Since: 2.26

getMicrosecond

dateTimeGetMicrosecond #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

datetime: a DateTime

-> m Int32

Returns: the microsecond of the second

Retrieves the microsecond of the date represented by datetime

Since: 2.26

getMinute

dateTimeGetMinute #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

datetime: a DateTime

-> m Int32

Returns: the minute of the hour

Retrieves the minute of the hour represented by datetime

Since: 2.26

getMonth

dateTimeGetMonth #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

datetime: a DateTime

-> m Int32

Returns: the month represented by datetime

Retrieves the month of the year represented by datetime in the Gregorian calendar.

Since: 2.26

getSecond

dateTimeGetSecond #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

datetime: a DateTime

-> m Int32

Returns: the second represented by datetime

Retrieves the second of the minute represented by datetime

Since: 2.26

getSeconds

dateTimeGetSeconds #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

datetime: a DateTime

-> m Double

Returns: the number of seconds

Retrieves the number of seconds since the start of the last minute, including the fractional part.

Since: 2.26

getTimezoneAbbreviation

dateTimeGetTimezoneAbbreviation #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

datetime: a DateTime

-> m Text

Returns: the time zone abbreviation. The returned string is owned by the DateTime and it should not be modified or freed

Determines the time zone abbreviation to be used at the time and in the time zone of datetime.

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

getUtcOffset

dateTimeGetUtcOffset #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

datetime: a DateTime

-> m Int64

Returns: the number of microseconds that should be added to UTC to get the local time

Determines the offset to UTC in effect at the time and in the time zone of datetime.

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

If datetime represents UTC time, then the offset is always zero.

Since: 2.26

getWeekNumberingYear

dateTimeGetWeekNumberingYear #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

datetime: a DateTime

-> m Int32

Returns: the ISO 8601 week-numbering year for datetime

Returns the ISO 8601 week-numbering year in which the week containing datetime falls.

This function, taken together with dateTimeGetWeekOfYear and dateTimeGetDayOfWeek can be used to determine the full ISO week date on which datetime falls.

This is usually equal to the normal Gregorian year (as returned by dateTimeGetYear), except as detailed below:

For Thursday, the week-numbering year is always equal to the usual calendar year. For other days, the number is such that every day within a complete week (Monday to Sunday) is contained within the same week-numbering year.

For Monday, Tuesday and Wednesday occurring near the end of the year, this may mean that the week-numbering year is one greater than the calendar year (so that these days have the same week-numbering year as the Thursday occurring early in the next year).

For Friday, Saturday and Sunday occurring near the start of the year, this may mean that the week-numbering year is one less than the calendar year (so that these days have the same week-numbering year as the Thursday occurring late in the previous year).

An equivalent description is that the week-numbering year is equal to the calendar year containing the majority of the days in the current week (Monday to Sunday).

Note that January 1 0001 in the proleptic Gregorian calendar is a Monday, so this function never returns 0.

Since: 2.26

getWeekOfYear

dateTimeGetWeekOfYear #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

datetime: a DateTime

-> m Int32

Returns: the ISO 8601 week number for datetime.

Returns the ISO 8601 week number for the week containing datetime. The ISO 8601 week number is the same for every day of the week (from Moday through Sunday). That can produce some unusual results (described below).

The first week of the year is week 1. This is the week that contains the first Thursday of the year. Equivalently, this is the first week that has more than 4 of its days falling within the calendar year.

The value 0 is never returned by this function. Days contained within a year but occurring before the first ISO 8601 week of that year are considered as being contained in the last week of the previous year. Similarly, the final days of a calendar year may be considered as being part of the first ISO 8601 week of the next year if 4 or more days of that week are contained within the new year.

Since: 2.26

getYear

dateTimeGetYear #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

datetime: A DateTime

-> m Int32

Returns: the year represented by datetime

Retrieves the year represented by datetime in the Gregorian calendar.

Since: 2.26

getYmd

dateTimeGetYmd #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

datetime: a DateTime.

-> m (Int32, Int32, Int32) 

Retrieves the Gregorian day, month, and year of a given DateTime.

Since: 2.26

hash

dateTimeHash #

Arguments

:: (HasCallStack, MonadIO m) 
=> Ptr ()

datetime: a DateTime

-> m Word32

Returns: a guint containing the hash

Hashes datetime into a guint, suitable for use within HashTable.

Since: 2.26

isDaylightSavings

dateTimeIsDaylightSavings #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

datetime: a DateTime

-> m Bool

Returns: True if daylight savings time is in effect

Determines if daylight savings time is in effect at the time and in the time zone of datetime.

Since: 2.26

new

dateTimeNew #

Arguments

:: (HasCallStack, MonadIO m) 
=> TimeZone

tz: a 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 DateTime, or Nothing

Creates a new 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 dateTimeUnref when you are done with it.

Since: 2.26

newFromTimevalLocal

dateTimeNewFromTimevalLocal #

Arguments

:: (HasCallStack, MonadIO m) 
=> TimeVal

tv: a TimeVal

-> m DateTime

Returns: a new DateTime, or Nothing

Creates a DateTime corresponding to the given TimeVal tv in the local time zone.

The time contained in a TimeVal is always stored in the form of seconds elapsed since 1970-01-01 00:00:00 UTC, regardless of the local time offset.

This call can fail (returning Nothing) if tv represents a time outside of the supported range of DateTime.

You should release the return value by calling dateTimeUnref when you are done with it.

Since: 2.26

newFromTimevalUtc

dateTimeNewFromTimevalUtc #

Arguments

:: (HasCallStack, MonadIO m) 
=> TimeVal

tv: a TimeVal

-> m DateTime

Returns: a new DateTime, or Nothing

Creates a DateTime corresponding to the given TimeVal tv in UTC.

The time contained in a TimeVal is always stored in the form of seconds elapsed since 1970-01-01 00:00:00 UTC.

This call can fail (returning Nothing) if tv represents a time outside of the supported range of DateTime.

You should release the return value by calling dateTimeUnref when you are done with it.

Since: 2.26

newFromUnixLocal

dateTimeNewFromUnixLocal #

Arguments

:: (HasCallStack, MonadIO m) 
=> Int64

t: the Unix time

-> m DateTime

Returns: a new DateTime, or Nothing

Creates a DateTime corresponding to the given Unix time t in the local time zone.

Unix time is the number of seconds that have elapsed since 1970-01-01 00:00:00 UTC, regardless of the local time offset.

This call can fail (returning Nothing) if t represents a time outside of the supported range of DateTime.

You should release the return value by calling dateTimeUnref when you are done with it.

Since: 2.26

newFromUnixUtc

dateTimeNewFromUnixUtc #

Arguments

:: (HasCallStack, MonadIO m) 
=> Int64

t: the Unix time

-> m DateTime

Returns: a new DateTime, or Nothing

Creates a DateTime corresponding to the given Unix time t in UTC.

Unix time is the number of seconds that have elapsed since 1970-01-01 00:00:00 UTC.

This call can fail (returning Nothing) if t represents a time outside of the supported range of DateTime.

You should release the return value by calling dateTimeUnref when you are done with it.

Since: 2.26

newLocal

dateTimeNewLocal #

Arguments

:: (HasCallStack, MonadIO m) 
=> 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 DateTime, or Nothing

Creates a new DateTime corresponding to the given date and time in the local time zone.

This call is equivalent to calling dateTimeNew with the time zone returned by timeZoneNewLocal.

Since: 2.26

newNow

dateTimeNewNow #

Arguments

:: (HasCallStack, MonadIO m) 
=> TimeZone

tz: a TimeZone

-> m DateTime

Returns: a new DateTime, or Nothing

Creates a DateTime corresponding to this exact instant in the given time zone tz. The time is as accurate as the system allows, to a maximum accuracy of 1 microsecond.

This function will always succeed unless the system clock is set to truly insane values (or unless GLib is still being used after the year 9999).

You should release the return value by calling dateTimeUnref when you are done with it.

Since: 2.26

newNowLocal

dateTimeNewNowLocal #

Arguments

:: (HasCallStack, MonadIO m) 
=> m DateTime

Returns: a new DateTime, or Nothing

Creates a DateTime corresponding to this exact instant in the local time zone.

This is equivalent to calling dateTimeNewNow with the time zone returned by timeZoneNewLocal.

Since: 2.26

newNowUtc

dateTimeNewNowUtc #

Arguments

:: (HasCallStack, MonadIO m) 
=> m DateTime

Returns: a new DateTime, or Nothing

Creates a DateTime corresponding to this exact instant in UTC.

This is equivalent to calling dateTimeNewNow with the time zone returned by timeZoneNewUtc.

Since: 2.26

newUtc

dateTimeNewUtc #

Arguments

:: (HasCallStack, MonadIO m) 
=> 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 DateTime, or Nothing

Creates a new DateTime corresponding to the given date and time in UTC.

This call is equivalent to calling dateTimeNew with the time zone returned by timeZoneNewUtc.

Since: 2.26

ref

data DateTimeRefMethodInfo #

Instances

((~) * signature (m DateTime), MonadIO m) => MethodInfo * DateTimeRefMethodInfo DateTime signature # 

dateTimeRef #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

datetime: a DateTime

-> m DateTime

Returns: the DateTime with the reference count increased

Atomically increments the reference count of datetime by one.

Since: 2.26

toLocal

dateTimeToLocal #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

datetime: a DateTime

-> m DateTime

Returns: the newly created DateTime

Creates a new DateTime corresponding to the same instant in time as datetime, but in the local time zone.

This call is equivalent to calling dateTimeToTimezone with the time zone returned by timeZoneNewLocal.

Since: 2.26

toTimeval

dateTimeToTimeval #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

datetime: a DateTime

-> TimeVal

tv: a TimeVal to modify

-> m Bool

Returns: True if successful, else False

Stores the instant in time that datetime represents into tv.

The time contained in a TimeVal is always stored in the form of seconds elapsed since 1970-01-01 00:00:00 UTC, regardless of the time zone associated with datetime.

On systems where 'long' is 32bit (ie: all 32bit systems and all Windows systems), a TimeVal is incapable of storing the entire range of values that DateTime is capable of expressing. On those systems, this function returns False to indicate that the time is out of range.

On systems where 'long' is 64bit, this function never fails.

Since: 2.26

toTimezone

dateTimeToTimezone #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

datetime: a DateTime

-> TimeZone

tz: the new TimeZone

-> m DateTime

Returns: a new DateTime, or Nothing

Create a new DateTime corresponding to the same instant in time as datetime, but in the time zone tz.

This call can fail in the case that the time goes out of bounds. For example, converting 0001-01-01 00:00:00 UTC to a time zone west of Greenwich will fail (due to the year 0 being out of range).

You should release the return value by calling dateTimeUnref when you are done with it.

Since: 2.26

toUnix

dateTimeToUnix #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

datetime: a DateTime

-> m Int64

Returns: the Unix time corresponding to datetime

Gives the Unix time corresponding to datetime, rounding down to the nearest second.

Unix time is the number of seconds that have elapsed since 1970-01-01 00:00:00 UTC, regardless of the time zone associated with datetime.

Since: 2.26

toUtc

dateTimeToUtc #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

datetime: a DateTime

-> m DateTime

Returns: the newly created DateTime

Creates a new DateTime corresponding to the same instant in time as datetime, but in UTC.

This call is equivalent to calling dateTimeToTimezone with the time zone returned by timeZoneNewUtc.

Since: 2.26

unref

data DateTimeUnrefMethodInfo #

Instances

((~) * signature (m ()), MonadIO m) => MethodInfo * DateTimeUnrefMethodInfo DateTime signature # 

dateTimeUnref #

Arguments

:: (HasCallStack, MonadIO m) 
=> DateTime

datetime: a DateTime

-> m () 

Atomically decrements the reference count of datetime by one.

When the reference count reaches zero, the resources allocated by datetime are freed

Since: 2.26