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
 

Macros

#define SDL_PROP_GLOBAL_SYSTEM_DATE_FORMAT_NUMBER   "SDL.time.date_format"
 
#define SDL_PROP_GLOBAL_SYSTEM_TIME_FORMAT_NUMBER   "SDL.time.time_format"
 

Enumerations

enum  SDL_DATE_FORMAT {
  SDL_DATE_FORMAT_YYYYMMDD = 0 ,
  SDL_DATE_FORMAT_DDMMYYYY = 1 ,
  SDL_DATE_FORMAT_MMDDYYYY = 2
}
 
enum  SDL_TIME_FORMAT {
  SDL_TIME_FORMAT_24HR = 0 ,
  SDL_TIME_FORMAT_12HR = 1
}
 

Functions

int SDL_GetCurrentTime (SDL_Time *ticks)
 
int SDL_TimeToDateTime (SDL_Time ticks, SDL_DateTime *dt, SDL_bool localTime)
 
int 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)
 

Detailed Description

Header for the SDL realtime clock and date/time routines.

Definition in file SDL_time.h.

Macro Definition Documentation

◆ SDL_PROP_GLOBAL_SYSTEM_DATE_FORMAT_NUMBER

#define SDL_PROP_GLOBAL_SYSTEM_DATE_FORMAT_NUMBER   "SDL.time.date_format"

Global date/time properties

  • SDL_PROP_GLOBAL_SYSTEM_DATE_FORMAT_NUMBER: the SDL_DATE_FORMAT to use as the preferred date display format for the current system locale.
  • SDL_PROP_GLOBAL_SYSTEM_TIME_FORMAT_NUMBER: the SDL_TIME_FORMAT to use as the preferred time display format for the current system locale.

Definition at line 87 of file SDL_time.h.

◆ SDL_PROP_GLOBAL_SYSTEM_TIME_FORMAT_NUMBER

#define SDL_PROP_GLOBAL_SYSTEM_TIME_FORMAT_NUMBER   "SDL.time.time_format"

Definition at line 88 of file SDL_time.h.

Enumeration Type Documentation

◆ SDL_DATE_FORMAT

The preferred date format of the current system locale.

See also
SDL_PROP_GLOBAL_SYSTEM_DATE_FORMAT_NUMBER
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 61 of file SDL_time.h.

62{
63 SDL_DATE_FORMAT_YYYYMMDD = 0, /**< Year/Month/Day */
64 SDL_DATE_FORMAT_DDMMYYYY = 1, /**< Day/Month/Year */
65 SDL_DATE_FORMAT_MMDDYYYY = 2, /**< Month/Day/Year */
SDL_DATE_FORMAT
Definition SDL_time.h:62
@ SDL_DATE_FORMAT_DDMMYYYY
Definition SDL_time.h:64
@ SDL_DATE_FORMAT_YYYYMMDD
Definition SDL_time.h:63
@ SDL_DATE_FORMAT_MMDDYYYY
Definition SDL_time.h:65

◆ SDL_TIME_FORMAT

The preferred time format of the current system locale.

See also
SDL_PROP_GLOBAL_SYSTEM_TIME_FORMAT_NUMBER
Enumerator
SDL_TIME_FORMAT_24HR 

24 hour time

SDL_TIME_FORMAT_12HR 

12 hour time

Definition at line 73 of file SDL_time.h.

74{
75 SDL_TIME_FORMAT_24HR = 0, /**< 24 hour time */
76 SDL_TIME_FORMAT_12HR = 1, /**< 12 hour time */
SDL_TIME_FORMAT
Definition SDL_time.h:74
@ SDL_TIME_FORMAT_12HR
Definition SDL_time.h:76
@ SDL_TIME_FORMAT_24HR
Definition SDL_time.h:75

Function Documentation

◆ SDL_DateTimeToTime()

int 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
0 on success or -1 on error; call SDL_GetError() for more information.
Since
This function is available since SDL 3.0.0

◆ SDL_GetCurrentTime()

int 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
0 on success or -1 on error; 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, otherwise -1; 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, otherwise -1; 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, otherwise -1; 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()

int SDL_TimeToDateTime ( SDL_Time  ticks,
SDL_DateTime dt,
SDL_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
0 on success or -1 on error; 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.