SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
Public Member Functions | List of all members
SDL::DateTime Struct Reference

A structure holding a calendar date and time broken down into its components. More...

Inheritance diagram for SDL::DateTime:
Inheritance graph
[legend]

Public Member Functions

constexpr DateTime (const SDL_DateTime &dateTime={})
 Wraps DateTime.
 
constexpr DateTime (int year, int month, int day, int hour, int minute, int second, int nanosecond, int day_of_week, int utc_offset)
 Constructs from its fields.
 
 DateTime (Time ticks, bool localTime=true)
 Converts an Time in nanoseconds since the epoch to a calendar time in the DateTime format.
 
constexpr operator bool () const
 Check if valid.
 
constexpr int GetYear () const
 Get the year.
 
constexpr DateTimeSetYear (int newYear)
 Set the year.
 
constexpr int GetMonth () const
 Get the month.
 
constexpr DateTimeSetMonth (int newMonth)
 Set the month.
 
constexpr int GetDay () const
 Get the day.
 
constexpr DateTimeSetDay (int newDay)
 Set the day.
 
constexpr int GetHour () const
 Get the hour.
 
constexpr DateTimeSetHour (int newHour)
 Set the hour.
 
constexpr int GetMinute () const
 Get the minute.
 
constexpr DateTimeSetMinute (int newMinute)
 Set the minute.
 
constexpr int GetSecond () const
 Get the second.
 
constexpr DateTimeSetSecond (int newSecond)
 Set the second.
 
constexpr int GetNanosecond () const
 Get the nanosecond.
 
constexpr DateTimeSetNanosecond (int newNanosecond)
 Set the nanosecond.
 
constexpr int GetDay_of_week () const
 Get the day_of_week.
 
constexpr DateTimeSetDay_of_week (int newDay_of_week)
 Set the day_of_week.
 
constexpr int GetUtc_offset () const
 Get the utc_offset.
 
constexpr DateTimeSetUtc_offset (int newUtc_offset)
 Set the utc_offset.
 
 operator Time () const
 Converts a calendar time to an Time in nanoseconds since the epoch.
 

Detailed Description

Since
This struct is available since SDL 3.2.0.

Constructor & Destructor Documentation

◆ DateTime() [1/3]

constexpr SDL::DateTime::DateTime ( const SDL_DateTime &  dateTime = {})
inlineconstexpr
Parameters
dateTimethe value to be wrapped

◆ DateTime() [2/3]

constexpr SDL::DateTime::DateTime ( int  year,
int  month,
int  day,
int  hour,
int  minute,
int  second,
int  nanosecond,
int  day_of_week,
int  utc_offset 
)
inlineconstexpr
Parameters
yearthe value for year.
monththe value for month.
daythe value for day.
hourthe value for hour.
minutethe value for minute.
secondthe value for second.
nanosecondthe value for nanosecond.
day_of_weekthe value for day_of_week.
utc_offsetthe value for utc_offset.

◆ DateTime() [3/3]

SDL::DateTime::DateTime ( Time  ticks,
bool  localTime = true 
)
inline
Parameters
ticksthe Time to be converted.
localTimethe resulting DateTime will be expressed in local time if true, otherwise it will be in Universal Coordinated Time (UTC).
Exceptions
Erroron failure.
Since
This function is available since SDL 3.2.0.

Member Function Documentation

◆ GetDay()

constexpr int SDL::DateTime::GetDay ( ) const
inlineconstexpr
Returns
current day value.

◆ GetDay_of_week()

constexpr int SDL::DateTime::GetDay_of_week ( ) const
inlineconstexpr
Returns
current day_of_week value.

◆ GetHour()

constexpr int SDL::DateTime::GetHour ( ) const
inlineconstexpr
Returns
current hour value.

◆ GetMinute()

constexpr int SDL::DateTime::GetMinute ( ) const
inlineconstexpr
Returns
current minute value.

◆ GetMonth()

constexpr int SDL::DateTime::GetMonth ( ) const
inlineconstexpr
Returns
current month value.

◆ GetNanosecond()

constexpr int SDL::DateTime::GetNanosecond ( ) const
inlineconstexpr
Returns
current nanosecond value.

◆ GetSecond()

constexpr int SDL::DateTime::GetSecond ( ) const
inlineconstexpr
Returns
current second value.

◆ GetUtc_offset()

constexpr int SDL::DateTime::GetUtc_offset ( ) const
inlineconstexpr
Returns
current utc_offset value.

◆ GetYear()

constexpr int SDL::DateTime::GetYear ( ) const
inlineconstexpr
Returns
current year value.

◆ operator bool()

constexpr SDL::DateTime::operator bool ( ) const
inlineexplicitconstexpr
Returns
True if valid state, false otherwise.

◆ operator Time()

SDL::DateTime::operator Time ( ) const
inline

This function ignores the day_of_week member of the DateTime struct, so it may remain unset.

Returns
time on success.
Exceptions
Erroron failure.
Since
This function is available since SDL 3.2.0.

◆ SetDay()

constexpr DateTime & SDL::DateTime::SetDay ( int  newDay)
inlineconstexpr
Parameters
newDaythe new day value.
Returns
Reference to self.

◆ SetDay_of_week()

constexpr DateTime & SDL::DateTime::SetDay_of_week ( int  newDay_of_week)
inlineconstexpr
Parameters
newDay_of_weekthe new day_of_week value.
Returns
Reference to self.

◆ SetHour()

constexpr DateTime & SDL::DateTime::SetHour ( int  newHour)
inlineconstexpr
Parameters
newHourthe new hour value.
Returns
Reference to self.

◆ SetMinute()

constexpr DateTime & SDL::DateTime::SetMinute ( int  newMinute)
inlineconstexpr
Parameters
newMinutethe new minute value.
Returns
Reference to self.

◆ SetMonth()

constexpr DateTime & SDL::DateTime::SetMonth ( int  newMonth)
inlineconstexpr
Parameters
newMonththe new month value.
Returns
Reference to self.

◆ SetNanosecond()

constexpr DateTime & SDL::DateTime::SetNanosecond ( int  newNanosecond)
inlineconstexpr
Parameters
newNanosecondthe new nanosecond value.
Returns
Reference to self.

◆ SetSecond()

constexpr DateTime & SDL::DateTime::SetSecond ( int  newSecond)
inlineconstexpr
Parameters
newSecondthe new second value.
Returns
Reference to self.

◆ SetUtc_offset()

constexpr DateTime & SDL::DateTime::SetUtc_offset ( int  newUtc_offset)
inlineconstexpr
Parameters
newUtc_offsetthe new utc_offset value.
Returns
Reference to self.

◆ SetYear()

constexpr DateTime & SDL::DateTime::SetYear ( int  newYear)
inlineconstexpr
Parameters
newYearthe new year value.
Returns
Reference to self.

The documentation for this struct was generated from the following file: