xentara-utils v2.0.4
The Xentara Utility Library
Loading...
Searching...
No Matches
xentara::utils::chrono::DecomposedTimePoint Class Referencefinal

A time point, decomposed into its components. More...

#include <xentara/utils/chrono/DecomposedTimePoint.hpp>

Public Member Functions

constexpr DecomposedTimePoint () noexcept=default
 Default constructor.
 
 DecomposedTimePoint (std::chrono::system_clock::time_point timePoint, const std::optional< std::chrono::minutes > &utcOffset=std::nullopt) noexcept
 Constructor for a specific time.
 
constexpr auto year () const noexcept -> int
 Gets the calendar year.
 
constexpr auto month () const noexcept -> unsigned int
 Gets the calendar month.
 
constexpr auto day () const noexcept -> unsigned int
 Gets the day of the month.
 
constexpr auto date () const noexcept -> const DecomposedDate &
 Gets the entire date.
 
constexpr auto hour () const noexcept -> unsigned int
 Gets the hour within the day.
 
constexpr auto minute () const noexcept -> unsigned int
 Gets the minute within the hour.
 
constexpr auto second () const noexcept -> unsigned int
 Gets the second within the minute.
 
constexpr auto nanosecond () const noexcept -> unsigned int
 Gets the number of nanoseconds after the second.
 
constexpr auto utcOffsetSign () const noexcept -> int
 Gets direction of the UTC offset.
 
constexpr auto utcOffsetHours () const noexcept -> unsigned int
 Gets the hours component of the time zone.
 
constexpr auto utcOffsetMinutes () const noexcept -> unsigned int
 Gets the minutes component of the time zone.
 

Detailed Description

A time point, decomposed into its components.

This class uses the so called “proleptic Gregorian calendar”, which is the Gregorian calendar extended to dates before October 15, 1582.

Constructor & Destructor Documentation

◆ DecomposedTimePoint() [1/2]

constexpr xentara::utils::chrono::DecomposedTimePoint::DecomposedTimePoint ( )
constexprdefaultnoexcept

Default constructor.

This constructor constructs a time point corresponding to 2001-01-01 00:00:00 UTC.

◆ DecomposedTimePoint() [2/2]

xentara::utils::chrono::DecomposedTimePoint::DecomposedTimePoint ( std::chrono::system_clock::time_point  timePoint,
const std::optional< std::chrono::minutes > &  utcOffset = std::nullopt 
)
noexcept

Constructor for a specific time.

Parameters
timePointThe time point.
utcOffsetThe UTC offset to represent the time in, or std::nullopt to use local time. The UTC offset only influences how the time is represented in the constructed object: timePoint must always be a regular UTC time without any offset. If you pass a time of 1 January 2001, 00:00:00.000 UTC and a UTC offset of +1 hours, the time will decomposed to 2001-01-01 01:00:00 UTC+01:00, for example.

Member Function Documentation

◆ date()

constexpr auto xentara::utils::chrono::DecomposedTimePoint::date ( ) const -> const DecomposedDate &
constexprnoexcept

Gets the entire date.

◆ day()

constexpr auto xentara::utils::chrono::DecomposedTimePoint::day ( ) const -> unsigned int
constexprnoexcept

Gets the day of the month.

Returns
The day of the month, between 1 and 31

◆ hour()

constexpr auto xentara::utils::chrono::DecomposedTimePoint::hour ( ) const -> unsigned int
constexprnoexcept

Gets the hour within the day.

Returns
The hour count, between 0 and 23

◆ minute()

constexpr auto xentara::utils::chrono::DecomposedTimePoint::minute ( ) const -> unsigned int
constexprnoexcept

Gets the minute within the hour.

Returns
The minute count, between 0 and 59

◆ month()

constexpr auto xentara::utils::chrono::DecomposedTimePoint::month ( ) const -> unsigned int
constexprnoexcept

Gets the calendar month.

Returns
The month number, between 1 and 12

◆ nanosecond()

constexpr auto xentara::utils::chrono::DecomposedTimePoint::nanosecond ( ) const -> unsigned int
constexprnoexcept

Gets the number of nanoseconds after the second.

Returns
The nanoseconds count, between 0 and 999,999,999

◆ second()

constexpr auto xentara::utils::chrono::DecomposedTimePoint::second ( ) const -> unsigned int
constexprnoexcept

Gets the second within the minute.

Note
Leap seconds are not represented.
Returns
The second count, between 0 and 59

◆ utcOffsetHours()

constexpr auto xentara::utils::chrono::DecomposedTimePoint::utcOffsetHours ( ) const -> unsigned int
constexprnoexcept

Gets the hours component of the time zone.

Returns
The hour component of the UTC offset.

◆ utcOffsetMinutes()

constexpr auto xentara::utils::chrono::DecomposedTimePoint::utcOffsetMinutes ( ) const -> unsigned int
constexprnoexcept

Gets the minutes component of the time zone.

Returns
The number of minutes West of Greenwich. Negative values are East, and positve values are West.

◆ utcOffsetSign()

constexpr auto xentara::utils::chrono::DecomposedTimePoint::utcOffsetSign ( ) const -> int
constexprnoexcept

Gets direction of the UTC offset.

Returns
-1 for negative offset, 0 for no offset, or +1 for positive offset.

◆ year()

constexpr auto xentara::utils::chrono::DecomposedTimePoint::year ( ) const -> int
constexprnoexcept

Gets the calendar year.

Returns
The year in the proleptic gregorian calendar. The value can be 0 or negative to represent years before the year 1 AD. 0 represents the year 1 B.C., 1 represents the year 2 B.C., etc.
Note
Please note that there is no “year 0“ in our calendar. The year 1 BC is immediately followed by the year 1 AD.