| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
SDL3.Sys.Time
Contents
Description
SDL realtime clock and date/time routines.
There are two data types that are used in this category: SDL_Time, which represents the nanoseconds since a specific moment (an "epoch"), and SDL_DateTime, which breaks time down into human-understandable components: years, months, days, hours, etc.
Much of the functionality is involved in converting those two types to other useful forms. A structure holding a calendar date and time broken down into its components.
FFI conventions
Unsuffixed aliases are unsafe foreign imports; aliases suffixed Safe are safe. Functions whose callbacks fire during the call export only the Safe alias (the genuine unsafe import stays reachable under SDL3.Sys.Bindgen.Time.Unsafe); functions curated unsafe-only export only the unsuffixed one. Each alias's documentation records its flavor and rationale.
Full conventions: SDL3.Sys.
Since: 3.2.0
Synopsis
- module SDL3.Sys.Bindgen.Time
- getDateTimeLocalePreferences :: Ptr SDL_DateFormat -> Ptr SDL_TimeFormat -> IO Bool
- getDateTimeLocalePreferencesSafe :: Ptr SDL_DateFormat -> Ptr SDL_TimeFormat -> IO Bool
- getCurrentTime :: Ptr SDL_Time -> IO Bool
- getCurrentTimeSafe :: Ptr SDL_Time -> IO Bool
- timeToDateTime :: SDL_Time -> Ptr SDL_DateTime -> Bool -> IO Bool
- timeToDateTimeSafe :: SDL_Time -> Ptr SDL_DateTime -> Bool -> IO Bool
- dateTimeToTime :: PtrConst SDL_DateTime -> Ptr SDL_Time -> IO Bool
- dateTimeToTimeSafe :: PtrConst SDL_DateTime -> Ptr SDL_Time -> IO Bool
- timeToWindows :: SDL_Time -> Ptr Uint32 -> Ptr Uint32 -> IO ()
- timeToWindowsSafe :: SDL_Time -> Ptr Uint32 -> Ptr Uint32 -> IO ()
- timeFromWindows :: Word32 -> Word32 -> IO SDL_Time
- timeFromWindowsSafe :: Word32 -> Word32 -> IO SDL_Time
- getDaysInMonth :: Int32 -> Int32 -> IO Int32
- getDaysInMonthSafe :: Int32 -> Int32 -> IO Int32
- getDayOfYear :: Int32 -> Int32 -> Int32 -> IO Int32
- getDayOfYearSafe :: Int32 -> Int32 -> Int32 -> IO Int32
- getDayOfWeek :: Int32 -> Int32 -> Int32 -> IO Int32
- getDayOfWeekSafe :: Int32 -> Int32 -> Int32 -> IO Int32
Documentation
module SDL3.Sys.Bindgen.Time
Function aliases
getDateTimeLocalePreferences Source #
Arguments
| :: Ptr SDL_DateFormat |
|
| -> Ptr SDL_TimeFormat |
|
| -> IO Bool |
Gets the current preferred date and time format for the system locale.
This might be a "slow" call that has to query the operating system. It's best to ask for this once and save the results. However, the preferred formats can change, usually because the user has changed a system preference outside of your program.
- Returns
- true on success or false on failure; call
getErrorfor more information. - Thread safety
- This function is not thread safe.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GetDateTimeLocalePreferences. The safe flavor isgetDateTimeLocalePreferencesSafe. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_GetDateTimeLocalePreferences, defined atSDL3/SDL_time.h 113:34
Since: 3.2.0
getDateTimeLocalePreferencesSafe Source #
Arguments
| :: Ptr SDL_DateFormat |
|
| -> Ptr SDL_TimeFormat |
|
| -> IO Bool |
Gets the current preferred date and time format for the system locale.
This might be a "slow" call that has to query the operating system. It's best to ask for this once and save the results. However, the preferred formats can change, usually because the user has changed a system preference outside of your program.
- Returns
- true on success or false on failure; call
getErrorfor more information. - Thread safety
- This function is not thread safe.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GetDateTimeLocalePreferences. The unsafe flavor isgetDateTimeLocalePreferences. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_GetDateTimeLocalePreferences, defined atSDL3/SDL_time.h 113:34
Since: 3.2.0
Gets the current value of the system realtime clock in nanoseconds since Jan 1, 1970 in Universal Coordinated Time (UTC).
- Returns
- true on success or false on failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GetCurrentTime. The safe flavor isgetCurrentTimeSafe. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_GetCurrentTime, defined atSDL3/SDL_time.h 127:34
Since: 3.2.0
Gets the current value of the system realtime clock in nanoseconds since Jan 1, 1970 in Universal Coordinated Time (UTC).
- Returns
- true on success or false on failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GetCurrentTime. The unsafe flavor isgetCurrentTime. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_GetCurrentTime, defined atSDL3/SDL_time.h 127:34
Since: 3.2.0
Arguments
| :: SDL_Time |
|
| -> Ptr SDL_DateTime |
|
| -> Bool |
|
| -> IO Bool |
Converts an SDL_Time in nanoseconds since the epoch to a calendar time in the SDL_DateTime format.
- Returns
- true on success or false on failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_TimeToDateTime. The safe flavor istimeToDateTimeSafe. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_TimeToDateTime, defined atSDL3/SDL_time.h 145:34
Since: 3.2.0
Arguments
| :: SDL_Time |
|
| -> Ptr SDL_DateTime |
|
| -> Bool |
|
| -> IO Bool |
Converts an SDL_Time in nanoseconds since the epoch to a calendar time in the SDL_DateTime format.
- Returns
- true on success or false on failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_TimeToDateTime. The unsafe flavor istimeToDateTime. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_TimeToDateTime, defined atSDL3/SDL_time.h 145:34
Since: 3.2.0
Arguments
| :: PtrConst SDL_DateTime |
|
| -> Ptr SDL_Time |
|
| -> IO Bool |
Converts a calendar time to an SDL_Time in nanoseconds since the epoch.
This function ignores the day_of_week member of the SDL_DateTime struct, so it may remain unset.
- Returns
- true on success or false on failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_DateTimeToTime. The safe flavor isdateTimeToTimeSafe. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_DateTimeToTime, defined atSDL3/SDL_time.h 162:34
Since: 3.2.0
Arguments
| :: PtrConst SDL_DateTime |
|
| -> Ptr SDL_Time |
|
| -> IO Bool |
Converts a calendar time to an SDL_Time in nanoseconds since the epoch.
This function ignores the day_of_week member of the SDL_DateTime struct, so it may remain unset.
- Returns
- true on success or false on failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_DateTimeToTime. The unsafe flavor isdateTimeToTime. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_DateTimeToTime, defined atSDL3/SDL_time.h 162:34
Since: 3.2.0
Arguments
| :: SDL_Time |
|
| -> Ptr Uint32 |
|
| -> Ptr Uint32 |
|
| -> IO () |
Converts an SDL time into a Windows FILETIME (100-nanosecond intervals since January 1, 1601).
This function fills in the two 32-bit values of the FILETIME structure.
- Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_TimeToWindows. The safe flavor istimeToWindowsSafe. - C declaration
SDL_TimeToWindows, defined atSDL3/SDL_time.h 180:34
Since: 3.2.0
Arguments
| :: SDL_Time |
|
| -> Ptr Uint32 |
|
| -> Ptr Uint32 |
|
| -> IO () |
Converts an SDL time into a Windows FILETIME (100-nanosecond intervals since January 1, 1601).
This function fills in the two 32-bit values of the FILETIME structure.
- Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_TimeToWindows. The unsafe flavor istimeToWindows. - C declaration
SDL_TimeToWindows, defined atSDL3/SDL_time.h 180:34
Since: 3.2.0
Arguments
| :: Word32 |
|
| -> Word32 |
|
| -> IO SDL_Time |
Converts a Windows FILETIME (100-nanosecond intervals since January 1, 1601) to an SDL time.
This function takes the two 32-bit values of the FILETIME structure as parameters.
- Returns
- the converted SDL time.
- Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_TimeFromWindows. The safe flavor istimeFromWindowsSafe. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_TimeFromWindows, defined atSDL3/SDL_time.h 197:38
Since: 3.2.0
Arguments
| :: Word32 |
|
| -> Word32 |
|
| -> IO SDL_Time |
Converts a Windows FILETIME (100-nanosecond intervals since January 1, 1601) to an SDL time.
This function takes the two 32-bit values of the FILETIME structure as parameters.
- Returns
- the converted SDL time.
- Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_TimeFromWindows. The unsafe flavor istimeFromWindows. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_TimeFromWindows, defined atSDL3/SDL_time.h 197:38
Since: 3.2.0
Get the number of days in a month for a given year.
- Returns
- the number of days in the requested month or -1 on failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GetDaysInMonth. The safe flavor isgetDaysInMonthSafe. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_GetDaysInMonth, defined atSDL3/SDL_time.h 211:33
Since: 3.2.0
Get the number of days in a month for a given year.
- Returns
- the number of days in the requested month or -1 on failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GetDaysInMonth. The unsafe flavor isgetDaysInMonth. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_GetDaysInMonth, defined atSDL3/SDL_time.h 211:33
Since: 3.2.0
Arguments
| :: Int32 |
|
| -> Int32 |
|
| -> Int32 |
|
| -> IO Int32 |
Get the day of year for a calendar date.
- Returns
- the day of year [0-365] if the date is valid or -1 on failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GetDayOfYear. The safe flavor isgetDayOfYearSafe. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_GetDayOfYear, defined atSDL3/SDL_time.h 226:33
Since: 3.2.0
Arguments
| :: Int32 |
|
| -> Int32 |
|
| -> Int32 |
|
| -> IO Int32 |
Get the day of year for a calendar date.
- Returns
- the day of year [0-365] if the date is valid or -1 on failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GetDayOfYear. The unsafe flavor isgetDayOfYear. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_GetDayOfYear, defined atSDL3/SDL_time.h 226:33
Since: 3.2.0
Arguments
| :: Int32 |
|
| -> Int32 |
|
| -> Int32 |
|
| -> IO Int32 |
Get the day of week for a calendar date.
- Returns
- a value between 0 and 6 (0 being Sunday) if the date is valid or -1 on failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GetDayOfWeek. The safe flavor isgetDayOfWeekSafe. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_GetDayOfWeek, defined atSDL3/SDL_time.h 241:33
Since: 3.2.0
Arguments
| :: Int32 |
|
| -> Int32 |
|
| -> Int32 |
|
| -> IO Int32 |
Get the day of week for a calendar date.
- Returns
- a value between 0 and 6 (0 being Sunday) if the date is valid or -1 on failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GetDayOfWeek. The unsafe flavor isgetDayOfWeek. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_GetDayOfWeek, defined atSDL3/SDL_time.h 241:33
Since: 3.2.0