4#include <SDL3/SDL_time.h>
5#include "SDL3pp_stdinc.h"
38 constexpr DateTime(
const SDL_DateTime& dateTime = {})
39 : SDL_DateTime(dateTime)
99 constexpr explicit operator bool()
const
101 return year != 0 || month != 0 || day != 0 || hour != 0 || minute != 0 ||
102 second != 0 || nanosecond != 0;
110 constexpr int GetYear()
const {
return year; }
148 constexpr int GetDay()
const {
return day; }
167 constexpr int GetHour()
const {
return hour; }
234 nanosecond = newNanosecond;
253 day_of_week = newDay_of_week;
272 utc_offset = newUtc_offset;
305 SDL_DATE_FORMAT_YYYYMMDD;
308 SDL_DATE_FORMAT_DDMMYYYY;
311 SDL_DATE_FORMAT_MMDDYYYY;
345 CheckError(SDL_GetDateTimeLocalePreferences(dateFormat, timeFormat));
378 SDL_TimeToWindows(
ToNS(), dwLowDateTime, dwHighDateTime);
396 return Time::FromNS(SDL_TimeFromWindows(dwLowDateTime, dwHighDateTime));
411 return CheckError(SDL_GetDaysInMonth(year, month), -1);
427 return CheckError(SDL_GetDayOfYear(year, month, day), -1);
443 return CheckError(SDL_GetDayOfWeek(year, month, day), -1);
SDL times are signed, 64-bit integers representing nanoseconds since the Unix epoch (Jan 1,...
Definition SDL3pp_stdinc.h:293
constexpr Sint64 ToNS() const
Converts to nanoseconds Sint64.
Definition SDL3pp_stdinc.h:329
static constexpr Time FromNS(Sint64 time)
Create from a nanoseconds Sint64.
Definition SDL3pp_stdinc.h:323
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition SDL3pp_error.h:206
SDL_TimeFormat TimeFormat
The preferred time format of the current system locale.
Definition SDL3pp_time.h:320
static Time FromWindows(Uint32 dwLowDateTime, Uint32 dwHighDateTime)
Converts a Windows FILETIME (100-nanosecond intervals since January 1, 1601) to an SDL time.
Definition SDL3pp_time.h:394
void ToWindows(Uint32 *dwLowDateTime, Uint32 *dwHighDateTime) const
Converts an SDL time into a Windows FILETIME (100-nanosecond intervals since January 1,...
Definition SDL3pp_time.h:376
static Time Current()
Gets the current value of the system realtime clock in nanoseconds since Jan 1, 1970 in Universal Coo...
Definition SDL3pp_time.h:356
constexpr DateFormat DATE_FORMAT_DDMMYYYY
Day/Month/Year.
Definition SDL3pp_time.h:307
constexpr TimeFormat TIME_FORMAT_12HR
12 hour time
Definition SDL3pp_time.h:324
constexpr DateFormat DATE_FORMAT_MMDDYYYY
Month/Day/Year.
Definition SDL3pp_time.h:310
SDL_DateFormat DateFormat
The preferred date format of the current system locale.
Definition SDL3pp_time.h:302
constexpr DateFormat DATE_FORMAT_YYYYMMDD
Year/Month/Day.
Definition SDL3pp_time.h:304
constexpr TimeFormat TIME_FORMAT_24HR
24 hour time
Definition SDL3pp_time.h:322
int GetDayOfYear(int year, int month, int day)
Get the day of year for a calendar date.
Definition SDL3pp_time.h:425
int GetDaysInMonth(int year, int month)
Get the number of days in a month for a given year.
Definition SDL3pp_time.h:409
int GetDayOfWeek(int year, int month, int day)
Get the day of week for a calendar date.
Definition SDL3pp_time.h:441
void GetDateTimeLocalePreferences(DateFormat *dateFormat, TimeFormat *timeFormat)
Gets the current preferred date and time format for the system locale.
Definition SDL3pp_time.h:342
the main namespace where all SDL3pp public functions and types live
Definition SDL3pp_assert.h:7
A structure holding a calendar date and time broken down into its components.
Definition SDL3pp_time.h:32
constexpr DateTime & SetMonth(int newMonth)
Set the month.
Definition SDL3pp_time.h:137
constexpr DateTime & SetUtc_offset(int newUtc_offset)
Set the utc_offset.
Definition SDL3pp_time.h:270
constexpr DateTime & SetMinute(int newMinute)
Set the minute.
Definition SDL3pp_time.h:194
constexpr DateTime & SetDay_of_week(int newDay_of_week)
Set the day_of_week.
Definition SDL3pp_time.h:251
constexpr int GetMonth() const
Get the month.
Definition SDL3pp_time.h:129
constexpr DateTime(const SDL_DateTime &dateTime={})
Wraps DateTime.
Definition SDL3pp_time.h:38
constexpr int GetYear() const
Get the year.
Definition SDL3pp_time.h:110
constexpr int GetSecond() const
Get the second.
Definition SDL3pp_time.h:205
constexpr int GetUtc_offset() const
Get the utc_offset.
Definition SDL3pp_time.h:262
constexpr int GetMinute() const
Get the minute.
Definition SDL3pp_time.h:186
constexpr int GetHour() const
Get the hour.
Definition SDL3pp_time.h:167
constexpr int GetNanosecond() const
Get the nanosecond.
Definition SDL3pp_time.h:224
constexpr DateTime & SetDay(int newDay)
Set the day.
Definition SDL3pp_time.h:156
constexpr int GetDay() const
Get the day.
Definition SDL3pp_time.h:148
constexpr DateTime & SetNanosecond(int newNanosecond)
Set the nanosecond.
Definition SDL3pp_time.h:232
DateTime(Time ticks, bool localTime=true)
Converts an Time in nanoseconds since the epoch to a calendar time in the DateTime format.
Definition SDL3pp_time.h:89
constexpr DateTime & SetYear(int newYear)
Set the year.
Definition SDL3pp_time.h:118
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.
Definition SDL3pp_time.h:56
constexpr int GetDay_of_week() const
Get the day_of_week.
Definition SDL3pp_time.h:243
constexpr DateTime & SetSecond(int newSecond)
Set the second.
Definition SDL3pp_time.h:213
constexpr DateTime & SetHour(int newHour)
Set the hour.
Definition SDL3pp_time.h:175