SDL 3.0
SDL_time.h File Reference
+ 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

The preferred date format of the current system locale.

Since
This enum is available since SDL 3.0.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 66 of file SDL_time.h.

67{
68 SDL_DATE_FORMAT_YYYYMMDD = 0, /**< Year/Month/Day */
69 SDL_DATE_FORMAT_DDMMYYYY = 1, /**< Day/Month/Year */
70 SDL_DATE_FORMAT_MMDDYYYY = 2 /**< Month/Day/Year */
SDL_DateFormat
Definition SDL_time.h:67
@ SDL_DATE_FORMAT_DDMMYYYY
Definition SDL_time.h:69
@ SDL_DATE_FORMAT_YYYYMMDD
Definition SDL_time.h:68
@ SDL_DATE_FORMAT_MMDDYYYY
Definition SDL_time.h:70

◆ SDL_TimeFormat

The preferred time format of the current system locale.

Since
This enum is available since SDL 3.0.0.
See also
SDL_GetDateTimeLocalePreferences
Enumerator
SDL_TIME_FORMAT_24HR 

24 hour time

SDL_TIME_FORMAT_12HR 

12 hour time

Definition at line 80 of file SDL_time.h.

81{
82 SDL_TIME_FORMAT_24HR = 0, /**< 24 hour time */
83 SDL_TIME_FORMAT_12HR = 1 /**< 12 hour time */
SDL_TimeFormat
Definition SDL_time.h:81
@ SDL_TIME_FORMAT_12HR
Definition SDL_time.h:83
@ SDL_TIME_FORMAT_24HR
Definition SDL_time.h:82

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
dtthe source SDL_DateTime.
ticksthe resulting SDL_Time.
Returns
true on success or false on failure; call SDL_GetError() for more information.
Since
This function is available since SDL 3.0.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
ticksthe SDL_Time to hold the returned tick count.
Returns
true on success or false on failure; call SDL_GetError() for more information.
Since
This function is available since SDL 3.0.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
dateFormata pointer to the SDL_DateFormat to hold the returned date format, may be NULL.
timeFormata 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.
Since
This function is available since SDL 3.0.0.

◆ SDL_GetDayOfWeek()

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

Get the day of week for a calendar date.

Parameters
yearthe year component of the date.
monththe month component of the date.
daythe 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.
Since
This function is available since SDL 3.0.0.

◆ SDL_GetDayOfYear()

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

Get the day of year for a calendar date.

Parameters
yearthe year component of the date.
monththe month component of the date.
daythe 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.
Since
This function is available since SDL 3.0.0.

◆ SDL_GetDaysInMonth()

int SDL_GetDaysInMonth ( int  year,
int  month 
)
extern

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

Parameters
yearthe year.
monththe month [1-12].
Returns
the number of days in the requested month or -1 on failure; call SDL_GetError() for more information.
Since
This function is available since SDL 3.0.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
dwLowDateTimethe low portion of the Windows FILETIME value.
dwHighDateTimethe high portion of the Windows FILETIME value.
Returns
the converted SDL time.
Since
This function is available since SDL 3.0.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
ticksthe SDL_Time to be converted.
dtthe resulting SDL_DateTime.
localTimethe 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.
Since
This function is available since SDL 3.0.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
ticksthe time to convert.
dwLowDateTimea pointer filled in with the low portion of the Windows FILETIME value.
dwHighDateTimea pointer filled in with the high portion of the Windows FILETIME value.
Since
This function is available since SDL 3.0.0.