A class to represent a date/time.
More...
#include <Time.h>
|
|
using | Option = std::optional<Time> |
| | Optional.
|
| |
|
|
static constexpr uint8_t | minDay = 1 |
| | Minimum acceptable day value.
|
| |
|
static constexpr uint8_t | maxDay = 31 |
| | Maximum acceptable day value.
|
| |
|
static constexpr uint8_t | minMonth = 1 |
| | Minimum acceptable month value.
|
| |
|
static constexpr uint8_t | maxMonth = 12 |
| | Maximum acceptable month value.
|
| |
|
static constexpr uint8_t | maxHour = 23 |
| | Maximum acceptable hour value.
|
| |
|
static constexpr uint8_t | maxMinute = 59 |
| | Maximum acceptable minute value.
|
| |
|
static constexpr uint8_t | maxSecond = 59 |
| | Maximum acceptable second value.
|
| |
A class to represent a date/time.
◆ Time() [1/6]
| Time::Time |
( |
bool | isUTCTime = true | ) |
|
Constructor
- Parameters
-
| isUTCTime | Construct with UTC time (false = set local time with UTC offset) |
◆ Time() [2/6]
| Time::Time |
( |
std::filesystem::file_time_type | fileTime | ) |
|
Constructor
- Parameters
-
| fileTime | A file system time point |
◆ Time() [3/6]
| Time::Time |
( |
time_t | time | ) |
|
◆ Time() [4/6]
| active::utility::Time::Time |
( |
int64_t | seconds | ) |
|
|
inline |
◆ Time() [5/6]
| active::utility::Time::Time |
( |
double | seconds | ) |
|
|
inline |
◆ Time() [6/6]
| Time::Time |
( |
int32_t | year, |
|
|
std::chrono::month | month, |
|
|
uint8_t | day, |
|
|
uint8_t | hour = 0, |
|
|
uint8_t | minute = 0, |
|
|
double | second = 0, |
|
|
int16_t | utcOffset = 0 ) |
Constructor (NB: Will throw exception if an invalid date is specified)
- Parameters
-
| year | The year |
| month | The month |
| day | The day |
| hour | The hour |
| minute | The minute |
| second | The second |
| utcOffset | The UTC offset |
◆ addDays()
| Time & Time::addDays |
( |
int16_t | daystoAdd | ) |
|
Add a specified number of days to the time
- Parameters
-
| daystoAdd | The number of days to add (can be negative) |
- Returns
- A reference to this
◆ addHours()
| Time & Time::addHours |
( |
int16_t | hourstoAdd | ) |
|
Add a specified number of hours to the time
- Parameters
-
| hourstoAdd | The number of hours to add (can be negative) |
- Returns
- A reference to this
◆ addMinutes()
| Time & Time::addMinutes |
( |
int16_t | minstoAdd | ) |
|
Add a specified number of minutes to the time
- Parameters
-
| minstoAdd | The number of minutes to add (can be negative) |
- Returns
- A reference to this
◆ addSeconds()
| Time & Time::addSeconds |
( |
double | secsToAdd | ) |
|
Add a specified number of seconds to the time
- Parameters
-
| secsToAdd | The number of seconds to add (can be negative, any fractional part is assigned to milliseconds) |
- Returns
- A reference to this
◆ compare()
| std::strong_ordering Time::compare |
( |
const Time & | ref, |
|
|
std::optional< double > | epsMicrosec = std::nullopt ) const |
Three-way comparison to another time
- Parameters
-
| ref | The object to compare |
| epsMicrosec | Precision for comparing the microsecond values (nullopt = use full precision) |
- Returns
- The relationship between this and ref (less, equal, greater)
◆ day()
| uint8_t active::utility::Time::day |
( |
| ) |
const |
|
inline |
Get the day (1-31)
- Returns
- The day
◆ differenceInDays()
| int64_t Time::differenceInDays |
( |
const Time & | other | ) |
const |
Get the difference in days between the time in this object and the other input
- Parameters
-
| other | The other time to get the difference to |
- Returns
- The difference in days
◆ differenceInHours()
| int64_t Time::differenceInHours |
( |
const Time & | other | ) |
const |
Get the difference in hours between the time in this object and the other input
- Parameters
-
| other | The other time to get the difference to |
- Returns
- The difference in hours
◆ differenceInMinutes()
| int64_t Time::differenceInMinutes |
( |
const Time & | other | ) |
const |
Get the difference in minutes between the time in this object and the other input
- Parameters
-
| other | The other time to get the difference to |
- Returns
- The difference in minutes
◆ differenceInSeconds()
| double Time::differenceInSeconds |
( |
const Time & | other | ) |
const |
Get the difference in seconds between the time in this object and the other input
- Parameters
-
| other | The other time to get the difference to |
- Returns
- The difference in seconds
◆ getUTCOffset()
| std::pair< int16_t, int16_t > Time::getUTCOffset |
( |
| ) |
const |
Get the UTC offset
- Returns
- A pair specifying offset hours and offset minutes
◆ hour()
| uint8_t active::utility::Time::hour |
( |
| ) |
const |
|
inline |
Get the hour (0-23)
- Returns
- The hour
◆ microsecond()
| uint32_t active::utility::Time::microsecond |
( |
| ) |
const |
|
inline |
Get the microsecond (0-999999)
- Returns
- The microsecond
◆ minute()
| uint8_t active::utility::Time::minute |
( |
| ) |
const |
|
inline |
Get the minute (0-59)
- Returns
- The minute
◆ month()
| std::chrono::month active::utility::Time::month |
( |
| ) |
const |
|
inline |
Get the month (1 - 12)
- Returns
- The month
◆ operator std::chrono::system_clock::time_point()
| Time::operator std::chrono::system_clock::time_point |
( |
| ) |
const |
Conversion operator
- Returns
- An equivalent system clock time_point
◆ operator!=()
| bool active::utility::Time::operator!= |
( |
const Time & | ref | ) |
const |
|
inline |
Equality operator
- Parameters
-
- Returns
- True if this matches ref
◆ operator+=()
| Time & Time::operator+= |
( |
int32_t | days | ) |
|
Addition with assignment operator
- Parameters
-
| days | The number of days to add |
- Returns
- A reference to this
◆ operator<=>()
| std::strong_ordering active::utility::Time::operator<=> |
( |
const Time & | ref | ) |
const |
|
inline |
Three-way comparison operator
- Parameters
-
- Returns
- The relationship between this and ref (less, equal, greater)
◆ operator=()
| Time & Time::operator= |
( |
const std::chrono::system_clock::time_point & | source | ) |
|
Assignment operator
- Parameters
-
| source | The object to assign |
- Returns
- A reference to this
◆ operator==()
| bool active::utility::Time::operator== |
( |
const Time & | ref | ) |
const |
|
inline |
Equality operator
- Parameters
-
- Returns
- True if this matches ref (NB: microseconds are included in this comparison - use
isEqual to control or ignore microseconds)
◆ resetDate()
| Time & Time::resetDate |
( |
| ) |
|
Reset all the calendar date values to zero/start value (leaving the time untouched) return: A reference to this
◆ resetTime()
| Time & Time::resetTime |
( |
| ) |
|
Reset all the time values to zero (leaving the calendar date untouched) return: A reference to this
◆ second()
| uint8_t active::utility::Time::second |
( |
| ) |
const |
|
inline |
Get the second (0-59)
- Returns
- The second
◆ secondsSince1970()
| double Time::secondsSince1970 |
( |
| ) |
const |
Get the number of seconds elapsed since 00:00 hours, Jan 1, 1970 (Unix epoch)
- Returns
- The number of seconds
◆ setHour()
| void active::utility::Time::setHour |
( |
uint8_t | val | ) |
|
|
inline |
◆ setMicrosecond()
| void active::utility::Time::setMicrosecond |
( |
uint32_t | val | ) |
|
|
inline |
Set the millisecond (0-999999)
◆ setMinute()
| void active::utility::Time::setMinute |
( |
uint8_t | val | ) |
|
|
inline |
◆ setSecond()
| void active::utility::Time::setSecond |
( |
uint8_t | val | ) |
|
|
inline |
◆ setSecondsSince1970()
| void Time::setSecondsSince1970 |
( |
double | totalSeconds | ) |
|
Set the seconds since 00:00 hours, Jan 1, 1970 UTC
- Parameters
-
| totalSeconds | The total seconds since 00:00 hours, Jan 1, 1970 UTC |
◆ setToCurrent()
| Time & Time::setToCurrent |
( |
bool | isUTCTime = true | ) |
|
Set to the current time
- Parameters
-
| isUTCTime | Construct with UTC time (false = set local time with UTC offset) return: A reference to this |
◆ setUTCOffset()
| void active::utility::Time::setUTCOffset |
( |
int16_t | offset | ) |
|
|
inline |
Set the UTC offset (value can be -ve or +ve offset from UTC time)
- Parameters
-
| offset | The UTC offset in minutes (NB: all other date/time values remain unchanged, so the in effect this changes the time-point) |
◆ year()
| int64_t active::utility::Time::year |
( |
| ) |
const |
|
inline |
Get the year (0 - 32768, e.g. 2011)
- Returns
- The year
The documentation for this class was generated from the following files:
- /Users/rwessel/Documents/Development/ActiveLib/Active/Utility/Time.h
- /Users/rwessel/Documents/Development/ActiveLib/Active/Utility/Time.cpp