SDL_time.h File Reference
`#include <SDL3/SDL_error.h>`
`#include <SDL3/SDL_stdinc.h>`
`#include <SDL3/SDL_begin_code.h>`
`#include <SDL3/SDL_close_code.h>`
Include dependency graph for SDL_time.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Data Structures

struct | SDL_DateTime

## Enumerations

enum | SDL_DateFormat { SDL_DATE_FORMAT_YYYYMMDD = 0 , SDL_DATE_FORMAT_DDMMYYYY = 1 , SDL_DATE_FORMAT_MMDDYYYY = 2 }
enum | SDL_TimeFormat { SDL_TIME_FORMAT_24HR = 0 , SDL_TIME_FORMAT_12HR = 1 }

## Functions

bool | SDL_GetDateTimeLocalePreferences (SDL_DateFormat *dateFormat, SDL_TimeFormat *timeFormat)
bool | SDL_GetCurrentTime (SDL_Time *ticks)
bool | SDL_TimeToDateTime (SDL_Time ticks, SDL_DateTime *dt, bool localTime)
bool | SDL_DateTimeToTime (const SDL_DateTime *dt, SDL_Time *ticks)
void | SDL_TimeToWindows (SDL_Time ticks, Uint32 *dwLowDateTime, Uint32 *dwHighDateTime)
SDL_Time | SDL_TimeFromWindows (Uint32 dwLowDateTime, Uint32 dwHighDateTime)
int | SDL_GetDaysInMonth (int year, int month)
int | SDL_GetDayOfYear (int year, int month, int day)
int | SDL_GetDayOfWeek (int year, int month, int day)

## Enumeration Type Documentation

## SDL_DateFormat

enum SDL_DateFormat

The preferred date format of the current system locale.

Since
  This enum is available since SDL 3.2.0.

See also
  SDL_GetDateTimeLocalePreferences

Enumerator
SDL_DATE_FORMAT_YYYYMMDD | Year/Month/Day
SDL_DATE_FORMAT_DDMMYYYY | Day/Month/Year
SDL_DATE_FORMAT_MMDDYYYY | Month/Day/Year

Definition at line 74 of file SDL_time.h.

{
SDL_DATE_FORMAT_YYYYMMDD = 0, /**< Year/Month/Day */
SDL_DATE_FORMAT_DDMMYYYY = 1, /**< Day/Month/Year */
SDL_DATE_FORMAT_MMDDYYYY = 2 /**< Month/Day/Year */
} SDL_DateFormat;
SDL_DateFormat
SDL_DateFormat
Definition SDL_time.h:75
SDL_DATE_FORMAT_DDMMYYYY
@ SDL_DATE_FORMAT_DDMMYYYY
Definition SDL_time.h:77
SDL_DATE_FORMAT_YYYYMMDD
@ SDL_DATE_FORMAT_YYYYMMDD
Definition SDL_time.h:76
SDL_DATE_FORMAT_MMDDYYYY
@ SDL_DATE_FORMAT_MMDDYYYY
Definition SDL_time.h:78

## SDL_TimeFormat

enum SDL_TimeFormat

The preferred time format of the current system locale.

Since
  This enum is available since SDL 3.2.0.

See also
  SDL_GetDateTimeLocalePreferences

Enumerator
SDL_TIME_FORMAT_24HR | 24 hour time
SDL_TIME_FORMAT_12HR | 12 hour time

Definition at line 88 of file SDL_time.h.

{
SDL_TIME_FORMAT_24HR = 0, /**< 24 hour time */
SDL_TIME_FORMAT_12HR = 1 /**< 12 hour time */
} SDL_TimeFormat;
SDL_TimeFormat
SDL_TimeFormat
Definition SDL_time.h:89
SDL_TIME_FORMAT_12HR
@ SDL_TIME_FORMAT_12HR
Definition SDL_time.h:91
SDL_TIME_FORMAT_24HR
@ SDL_TIME_FORMAT_24HR
Definition SDL_time.h:90

## Function Documentation

## SDL_DateTimeToTime()

bool SDL_DateTimeToTime | ( | const SDL_DateTime * | dt,
|  | SDL_Time * | ticks )

extern

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.

Parameters

  dt | the source SDL_DateTime.
  ticks | the resulting SDL_Time.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

\threadsafety It is safe to call this function from any thread.

Since
  This function is available since SDL 3.2.0.

## SDL_GetCurrentTime()

bool SDL_GetCurrentTime | ( | SDL_Time * | ticks | ) |

extern

Gets the current value of the system realtime clock in nanoseconds since Jan 1, 1970 in Universal Coordinated Time (UTC).

Parameters

  ticks | the SDL_Time to hold the returned tick count.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

\threadsafety It is safe to call this function from any thread.

Since
  This function is available since SDL 3.2.0.

## SDL_GetDateTimeLocalePreferences()

bool SDL_GetDateTimeLocalePreferences | ( | SDL_DateFormat * | dateFormat,
|  | SDL_TimeFormat * | timeFormat )

extern

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.

Parameters

  dateFormat | a pointer to the SDL_DateFormat to hold the returned date format, may be NULL.
  timeFormat | a pointer to the SDL_TimeFormat to hold the returned time format, may be NULL.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

\threadsafety This function is not thread safe.

Since
  This function is available since SDL 3.2.0.

## SDL_GetDayOfWeek()

int SDL_GetDayOfWeek | ( | int | year,
|  | int | month,
|  | int | day )

extern

Get the day of week for a calendar date.

Parameters

  year | the year component of the date.
  month | the month component of the date.
  day | the day component of the date.

Returns
  a value between 0 and 6 (0 being Sunday) if the date is valid or -1 on failure; call SDL_GetError() for more information.

\threadsafety It is safe to call this function from any thread.

Since
  This function is available since SDL 3.2.0.

## SDL_GetDayOfYear()

int SDL_GetDayOfYear | ( | int | year,
|  | int | month,
|  | int | day )

extern

Get the day of year for a calendar date.

Parameters

  year | the year component of the date.
  month | the month component of the date.
  day | the day component of the date.

Returns
  the day of year [0-365] if the date is valid or -1 on failure; call SDL_GetError() for more information.

\threadsafety It is safe to call this function from any thread.

Since
  This function is available since SDL 3.2.0.

## SDL_GetDaysInMonth()

int SDL_GetDaysInMonth | ( | int | year,
|  | int | month )

extern

Get the number of days in a month for a given year.

Parameters

  year | the year.
  month | the month [1-12].

Returns
  the number of days in the requested month or -1 on failure; call SDL_GetError() for more information.

\threadsafety It is safe to call this function from any thread.

Since
  This function is available since SDL 3.2.0.

## SDL_TimeFromWindows()

SDL_Time SDL_TimeFromWindows | ( | Uint32 | dwLowDateTime,
|  | Uint32 | dwHighDateTime )

extern

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.

Parameters

  dwLowDateTime | the low portion of the Windows FILETIME value.
  dwHighDateTime | the high portion of the Windows FILETIME value.

Returns
  the converted SDL time.

\threadsafety It is safe to call this function from any thread.

Since
  This function is available since SDL 3.2.0.

## SDL_TimeToDateTime()

bool SDL_TimeToDateTime | ( | SDL_Time | ticks,
|  | SDL_DateTime * | dt,
|  | bool | localTime )

extern

Converts an SDL_Time in nanoseconds since the epoch to a calendar time in the SDL_DateTime format.

Parameters

  ticks | the SDL_Time to be converted.
  dt | the resulting SDL_DateTime.
  localTime | the resulting SDL_DateTime will be expressed in local time if true, otherwise it will be in Universal Coordinated Time (UTC).

Returns
  true on success or false on failure; call SDL_GetError() for more information.

\threadsafety It is safe to call this function from any thread.

Since
  This function is available since SDL 3.2.0.

## SDL_TimeToWindows()

void SDL_TimeToWindows | ( | SDL_Time | ticks,
|  | Uint32 * | dwLowDateTime,
|  | Uint32 * | dwHighDateTime )

extern

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.

Parameters

  ticks | the time to convert.
  dwLowDateTime | a pointer filled in with the low portion of the Windows FILETIME value.
  dwHighDateTime | a pointer filled in with the high portion of the Windows FILETIME value.

\threadsafety It is safe to call this function from any thread.

Since
  This function is available since SDL 3.2.0.