Lightweight 0.20250904.0
Loading...
Searching...
No Matches
Lightweight::SqlDateTime Struct Reference

#include <SqlDateTime.hpp>

Public Types

using native_type = std::chrono::system_clock::time_point
 
using duration_type = std::chrono::system_clock::duration
 

Public Member Functions

constexpr SqlDateTime (SqlDateTime &&) noexcept=default
 
constexpr SqlDateTimeoperator= (SqlDateTime &&) noexcept=default
 
constexpr SqlDateTime (SqlDateTime const &) noexcept=default
 
constexpr SqlDateTimeoperator= (SqlDateTime const &other) noexcept=default
 
constexpr std::weak_ordering operator<=> (SqlDateTime const &other) const noexcept
 
constexpr bool operator== (SqlDateTime const &other) const noexcept
 
constexpr bool operator!= (SqlDateTime const &other) const noexcept
 
LIGHTWEIGHT_FORCE_INLINE constexpr SqlDateTime (std::chrono::year_month_day ymd, std::chrono::hh_mm_ss< duration_type > time) noexcept
 Constructs a date and time from individual components.
 
LIGHTWEIGHT_FORCE_INLINE constexpr SqlDateTime (std::chrono::year year, std::chrono::month month, std::chrono::day day, std::chrono::hours hour, std::chrono::minutes minute, std::chrono::seconds second, std::chrono::nanoseconds nanosecond=std::chrono::nanoseconds(0)) noexcept
 Constructs a date and time from individual components.
 
LIGHTWEIGHT_FORCE_INLINE constexpr SqlDateTime (std::chrono::system_clock::time_point value) noexcept
 Constructs a date and time from a time point.
 
constexpr LIGHTWEIGHT_FORCE_INLINE std::chrono::year year () const noexcept
 Returns the year of this date-time object.
 
constexpr LIGHTWEIGHT_FORCE_INLINE std::chrono::month month () const noexcept
 Returns the month of this date-time object.
 
constexpr LIGHTWEIGHT_FORCE_INLINE std::chrono::day day () const noexcept
 Returns the day of this date-time object.
 
constexpr LIGHTWEIGHT_FORCE_INLINE std::chrono::hours hour () const noexcept
 Returns the hour of this date-time object.
 
constexpr LIGHTWEIGHT_FORCE_INLINE std::chrono::minutes minute () const noexcept
 Returns the minute of this date-time object.
 
constexpr LIGHTWEIGHT_FORCE_INLINE std::chrono::seconds second () const noexcept
 Returns the second of this date-time object.
 
constexpr LIGHTWEIGHT_FORCE_INLINE std::chrono::nanoseconds nanosecond () const noexcept
 Returns the nanosecond of this date-time object.
 
LIGHTWEIGHT_FORCE_INLINE constexpr operator native_type () const noexcept
 
constexpr LIGHTWEIGHT_FORCE_INLINE native_type value () const noexcept
 Returns the current date and time.
 
LIGHTWEIGHT_FORCE_INLINE SqlDateTimeoperator+= (duration_type duration) noexcept
 
LIGHTWEIGHT_FORCE_INLINE SqlDateTimeoperator-= (duration_type duration) noexcept
 

Static Public Member Functions

static LIGHTWEIGHT_FORCE_INLINE SqlDateTime Now () noexcept
 Returns the current date and time.
 
static LIGHTWEIGHT_FORCE_INLINE SqlDateTime NowUTC () noexcept
 Return the current date and time in UTC.
 
static LIGHTWEIGHT_FORCE_INLINE SQL_TIMESTAMP_STRUCT constexpr ConvertToSqlValue (native_type value) noexcept
 
static LIGHTWEIGHT_FORCE_INLINE SQL_TIMESTAMP_STRUCT constexpr ConvertToSqlValue (std::chrono::year_month_day ymd, std::chrono::hh_mm_ss< duration_type > hms) noexcept
 
static LIGHTWEIGHT_FORCE_INLINE native_type constexpr ConvertToNative (SQL_TIMESTAMP_STRUCT const &time) noexcept
 

Public Attributes

SQL_TIMESTAMP_STRUCT sqlValue {}
 

Detailed Description

Represents a date and time to efficiently write to or read from a database.

See also
SqlDate, SqlTime

Definition at line 22 of file SqlDateTime.hpp.

Member Typedef Documentation

◆ native_type

using Lightweight::SqlDateTime::native_type = std::chrono::system_clock::time_point

Definition at line 24 of file SqlDateTime.hpp.

◆ duration_type

using Lightweight::SqlDateTime::duration_type = std::chrono::system_clock::duration

Definition at line 25 of file SqlDateTime.hpp.

Constructor & Destructor Documentation

◆ SqlDateTime() [1/3]

LIGHTWEIGHT_FORCE_INLINE constexpr Lightweight::SqlDateTime::SqlDateTime ( std::chrono::year_month_day  ymd,
std::chrono::hh_mm_ss< duration_type >  time 
)
inlineconstexprnoexcept

Constructs a date and time from individual components.

Definition at line 63 of file SqlDateTime.hpp.

◆ SqlDateTime() [2/3]

LIGHTWEIGHT_FORCE_INLINE constexpr Lightweight::SqlDateTime::SqlDateTime ( std::chrono::year  year,
std::chrono::month  month,
std::chrono::day  day,
std::chrono::hours  hour,
std::chrono::minutes  minute,
std::chrono::seconds  second,
std::chrono::nanoseconds  nanosecond = std::chrono::nanoseconds(0) 
)
inlineconstexprnoexcept

Constructs a date and time from individual components.

Definition at line 79 of file SqlDateTime.hpp.

References day(), hour(), minute(), month(), nanosecond(), second(), and year().

◆ SqlDateTime() [3/3]

LIGHTWEIGHT_FORCE_INLINE constexpr Lightweight::SqlDateTime::SqlDateTime ( std::chrono::system_clock::time_point  value)
inlineconstexprnoexcept

Constructs a date and time from a time point.

Definition at line 100 of file SqlDateTime.hpp.

References value().

Member Function Documentation

◆ Now()

static LIGHTWEIGHT_FORCE_INLINE SqlDateTime Lightweight::SqlDateTime::Now ( )
inlinestaticnoexcept

Returns the current date and time.

Definition at line 28 of file SqlDateTime.hpp.

◆ NowUTC()

static LIGHTWEIGHT_FORCE_INLINE SqlDateTime Lightweight::SqlDateTime::NowUTC ( )
inlinestaticnoexcept

Return the current date and time in UTC.

Definition at line 35 of file SqlDateTime.hpp.

◆ operator<=>()

constexpr std::weak_ordering Lightweight::SqlDateTime::operator<=> ( SqlDateTime const &  other) const
inlineconstexprnoexcept

Definition at line 48 of file SqlDateTime.hpp.

◆ operator==()

constexpr bool Lightweight::SqlDateTime::operator== ( SqlDateTime const &  other) const
inlineconstexprnoexcept

Definition at line 52 of file SqlDateTime.hpp.

◆ operator!=()

constexpr bool Lightweight::SqlDateTime::operator!= ( SqlDateTime const &  other) const
inlineconstexprnoexcept

Definition at line 57 of file SqlDateTime.hpp.

◆ year()

constexpr LIGHTWEIGHT_FORCE_INLINE std::chrono::year Lightweight::SqlDateTime::year ( ) const
inlineconstexprnoexcept

Returns the year of this date-time object.

Definition at line 108 of file SqlDateTime.hpp.

Referenced by SqlDateTime().

◆ month()

constexpr LIGHTWEIGHT_FORCE_INLINE std::chrono::month Lightweight::SqlDateTime::month ( ) const
inlineconstexprnoexcept

Returns the month of this date-time object.

Definition at line 114 of file SqlDateTime.hpp.

Referenced by SqlDateTime().

◆ day()

constexpr LIGHTWEIGHT_FORCE_INLINE std::chrono::day Lightweight::SqlDateTime::day ( ) const
inlineconstexprnoexcept

Returns the day of this date-time object.

Definition at line 120 of file SqlDateTime.hpp.

Referenced by SqlDateTime().

◆ hour()

constexpr LIGHTWEIGHT_FORCE_INLINE std::chrono::hours Lightweight::SqlDateTime::hour ( ) const
inlineconstexprnoexcept

Returns the hour of this date-time object.

Definition at line 126 of file SqlDateTime.hpp.

Referenced by SqlDateTime().

◆ minute()

constexpr LIGHTWEIGHT_FORCE_INLINE std::chrono::minutes Lightweight::SqlDateTime::minute ( ) const
inlineconstexprnoexcept

Returns the minute of this date-time object.

Definition at line 132 of file SqlDateTime.hpp.

Referenced by SqlDateTime().

◆ second()

constexpr LIGHTWEIGHT_FORCE_INLINE std::chrono::seconds Lightweight::SqlDateTime::second ( ) const
inlineconstexprnoexcept

Returns the second of this date-time object.

Definition at line 138 of file SqlDateTime.hpp.

Referenced by SqlDateTime().

◆ nanosecond()

constexpr LIGHTWEIGHT_FORCE_INLINE std::chrono::nanoseconds Lightweight::SqlDateTime::nanosecond ( ) const
inlineconstexprnoexcept

Returns the nanosecond of this date-time object.

Definition at line 144 of file SqlDateTime.hpp.

Referenced by SqlDateTime().

◆ operator native_type()

LIGHTWEIGHT_FORCE_INLINE constexpr Lightweight::SqlDateTime::operator native_type ( ) const
inlineconstexprnoexcept

Definition at line 151 of file SqlDateTime.hpp.

◆ ConvertToSqlValue() [1/2]

static LIGHTWEIGHT_FORCE_INLINE SQL_TIMESTAMP_STRUCT constexpr Lightweight::SqlDateTime::ConvertToSqlValue ( native_type  value)
inlinestaticconstexprnoexcept

Definition at line 156 of file SqlDateTime.hpp.

◆ ConvertToSqlValue() [2/2]

static LIGHTWEIGHT_FORCE_INLINE SQL_TIMESTAMP_STRUCT constexpr Lightweight::SqlDateTime::ConvertToSqlValue ( std::chrono::year_month_day  ymd,
std::chrono::hh_mm_ss< duration_type >  hms 
)
inlinestaticconstexprnoexcept

Definition at line 166 of file SqlDateTime.hpp.

◆ ConvertToNative()

static LIGHTWEIGHT_FORCE_INLINE native_type constexpr Lightweight::SqlDateTime::ConvertToNative ( SQL_TIMESTAMP_STRUCT const &  time)
inlinestaticconstexprnoexcept

Definition at line 183 of file SqlDateTime.hpp.

◆ value()

constexpr LIGHTWEIGHT_FORCE_INLINE native_type Lightweight::SqlDateTime::value ( ) const
inlineconstexprnoexcept

Returns the current date and time.

Definition at line 201 of file SqlDateTime.hpp.

Referenced by SqlDateTime().

◆ operator+=()

LIGHTWEIGHT_FORCE_INLINE SqlDateTime & Lightweight::SqlDateTime::operator+= ( duration_type  duration)
inlinenoexcept

Definition at line 206 of file SqlDateTime.hpp.

◆ operator-=()

LIGHTWEIGHT_FORCE_INLINE SqlDateTime & Lightweight::SqlDateTime::operator-= ( duration_type  duration)
inlinenoexcept

Definition at line 212 of file SqlDateTime.hpp.

Member Data Documentation

◆ sqlValue

SQL_TIMESTAMP_STRUCT Lightweight::SqlDateTime::sqlValue {}

Definition at line 228 of file SqlDateTime.hpp.


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