SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
Classes | Typedefs | Functions | Variables
Date and Time

SDL realtime clock and date/time routines. More...

Classes

struct  SDL::DateTime
 A structure holding a calendar date and time broken down into its components. More...
 

Typedefs

using SDL::DateFormat = SDL_DateFormat
 The preferred date format of the current system locale.
 
using SDL::TimeFormat = SDL_TimeFormat
 The preferred time format of the current system locale.
 

Functions

void SDL::GetDateTimeLocalePreferences (DateFormat *dateFormat, TimeFormat *timeFormat)
 Gets the current preferred date and time format for the system locale.
 
int SDL::GetDaysInMonth (int year, int month)
 Get the number of days in a month for a given year.
 
int SDL::GetDayOfYear (int year, int month, int day)
 Get the day of year for a calendar date.
 
int SDL::GetDayOfWeek (int year, int month, int day)
 Get the day of week for a calendar date.
 
static Time SDL::Time::Current ()
 Gets the current value of the system realtime clock in nanoseconds since Jan 1, 1970 in Universal Coordinated Time (UTC).
 
void SDL::Time::ToWindows (Uint32 *dwLowDateTime, Uint32 *dwHighDateTime) const
 Converts an SDL time into a Windows FILETIME (100-nanosecond intervals since January 1, 1601).
 
static Time SDL::Time::FromWindows (Uint32 dwLowDateTime, Uint32 dwHighDateTime)
 Converts a Windows FILETIME (100-nanosecond intervals since January 1, 1601) to an SDL time.
 

Variables

constexpr DateFormat SDL::DATE_FORMAT_YYYYMMDD
 Year/Month/Day.
 
constexpr DateFormat SDL::DATE_FORMAT_DDMMYYYY
 Day/Month/Year.
 
constexpr DateFormat SDL::DATE_FORMAT_MMDDYYYY
 Month/Day/Year.
 
constexpr TimeFormat SDL::TIME_FORMAT_24HR = SDL_TIME_FORMAT_24HR
 24 hour time
 
constexpr TimeFormat SDL::TIME_FORMAT_12HR = SDL_TIME_FORMAT_12HR
 12 hour time
 

Detailed Description

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.

Typedef Documentation

◆ DateFormat

using SDL::DateFormat = typedef SDL_DateFormat
Since
This enum is available since SDL 3.2.0.
See also
GetDateTimeLocalePreferences

◆ TimeFormat

using SDL::TimeFormat = typedef SDL_TimeFormat
Since
This enum is available since SDL 3.2.0.
See also
GetDateTimeLocalePreferences

Function Documentation

◆ Current()

Time SDL::Time::Current ( )
inlinestatic
Exceptions
Erroron failure.
Since
This function is available since SDL 3.2.0.

◆ FromWindows()

Time SDL::Time::FromWindows ( Uint32  dwLowDateTime,
Uint32  dwHighDateTime 
)
inlinestatic

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.2.0.

◆ GetDateTimeLocalePreferences()

void SDL::GetDateTimeLocalePreferences ( DateFormat dateFormat,
TimeFormat timeFormat 
)
inline

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 DateFormat to hold the returned date format, may be nullptr.
timeFormata pointer to the TimeFormat to hold the returned time format, may be nullptr.
Exceptions
Erroron failure.
Since
This function is available since SDL 3.2.0.

◆ GetDayOfWeek()

int SDL::GetDayOfWeek ( int  year,
int  month,
int  day 
)
inline
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.
Exceptions
Erroron failure.
Since
This function is available since SDL 3.2.0.

◆ GetDayOfYear()

int SDL::GetDayOfYear ( int  year,
int  month,
int  day 
)
inline
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.
Exceptions
Erroron failure.
Since
This function is available since SDL 3.2.0.

◆ GetDaysInMonth()

int SDL::GetDaysInMonth ( int  year,
int  month 
)
inline
Parameters
yearthe year.
monththe month [1-12].
Returns
the number of days in the requested month.
Exceptions
Erroron failure.
Since
This function is available since SDL 3.2.0.

◆ ToWindows()

void SDL::Time::ToWindows ( Uint32 *  dwLowDateTime,
Uint32 *  dwHighDateTime 
) const
inline

This function fills in the two 32-bit values of the FILETIME structure.

Parameters
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.2.0.

Variable Documentation

◆ DATE_FORMAT_DDMMYYYY

constexpr DateFormat SDL::DATE_FORMAT_DDMMYYYY
constexpr
Initial value:
=
SDL_DATE_FORMAT_DDMMYYYY

◆ DATE_FORMAT_MMDDYYYY

constexpr DateFormat SDL::DATE_FORMAT_MMDDYYYY
constexpr
Initial value:
=
SDL_DATE_FORMAT_MMDDYYYY

◆ DATE_FORMAT_YYYYMMDD

constexpr DateFormat SDL::DATE_FORMAT_YYYYMMDD
constexpr
Initial value:
=
SDL_DATE_FORMAT_YYYYMMDD