34#include <NDEVR/BaseValues.h>
35#include <NDEVR/BufferBase.h>
88 static constexpr uint08 NANOSECOND = 1;
89 static constexpr uint08 MICROSECOND = 1000 * NANOSECOND;
90 static constexpr uint08 MILLISECOND = 1000000;
91 static constexpr uint08 SECOND = 1000000000;
92 static constexpr uint08 MINUTE = SECOND * 60;
93 static constexpr uint08 HOUR = MINUTE * 60;
94 static constexpr uint08 DAY = HOUR * 24;
95 static constexpr uint08 WEEK = DAY * 7;
96 static constexpr uint08 YEAR = DAY * 365;
97 static constexpr uint08 LEAP_YEAR = DAY * 366;
277 return m_time / MILLISECOND;
286 [[nodiscard]] NDEVR_BASE_API
uint08 leapYearConstant()
const;
287 [[nodiscard]] NDEVR_BASE_API
uint08 daysConstant()
const;
288 [[nodiscard]] NDEVR_BASE_API
uint08 monthsConstant()
const;
290 inline constexpr bool operator==(
const Time& time)
const
292 return m_time == time.m_time;
296 return m_time != time.m_time;
298 inline constexpr bool operator<(
const Time& time)
const
300 return m_time < time.m_time;
302 inline constexpr bool operator<=(
const Time& time)
const
304 return m_time <= time.m_time;
306 inline constexpr bool operator>(
const Time& time)
const
308 return m_time > time.m_time;
310 inline constexpr bool operator>=(
const Time& time)
const
312 return m_time >= time.m_time;
331 NDEVR_BASE_API
static void SetMakeUTCFromLocalFunction(
const std::function<
uint08(
const tm& tm)>& function);
332 NDEVR_BASE_API
static void SetMakeLocalFromUTCFunction(
const std::function<
uint08(
const tm& tm)>& function);
333 NDEVR_BASE_API
static void SetClockErrorCallback(
const std::function<
void(
const Exception& error)>& function);
335 static tm getTime(
sint08 time,
bool use_local_time);
336 static uint08 MakeGMTFromLocal(
const tm& time);
337 static uint08 MakeLocalFromGMT(
const tm& time);
339 static constexpr uint02 s_epoch_year = 1970;
340 static constexpr uint02 s_tm_year_base = 1900;
341 static std::function<
uint08(
const tm& tm)> s_make_utc_from_local;
342 static std::function<
uint08(
const tm& tm)> s_make_local_from_utc;
343 static std::function<void(
const Exception& error)> s_clock_error_callback;
344 static sint08 s_nano_second_offset;
360 static const uint01 Dimensions = 0;
361 static const bool Vector =
false;
362 static const bool Primitive =
true;
363 static const bool Pointer =
false;
364 static const bool Unsigned =
false;
365 static const bool Float =
true;
366 static const bool Integer =
false;
367 static const bool Number =
true;
368 static const bool String =
false;
369 static const bool Color =
false;
370 static const bool Buffer =
false;
371 static const bool Boolean =
false;
375 static_assert(
sizeof(
Time(0)) == 8,
"Bad time allocation size");
377 template<>
constexpr const Time Constant<Time>::Invalid =
Time(18446744073709551615ULL);
378 template<>
constexpr const Time Constant<Time>::Max =
Time(18446744073709551614ULL);
379 template<>
constexpr const Time Constant<Time>::Min =
Time(0);
Provides consistent interface to handle errors through the throw expression.
This class is like a string view, but may optionally store the data internally Useful if the return t...
The core String View class for the NDEVR API.
The core String class for the NDEVR API.
Represents a timestamp with utilities for manipulation and conversion.
StringAllocatingView getAsString(bool get_local_time, const StringView &format_string) const
Converts the timestamp to a string representation.
static void SetSystemTime(const Time &time)
Sets the application's system clock to a specified Time.
void setMonth(const Month &month, bool is_local_time)
Sets the month (1-12).
Time(uint04 year, uint04 month, uint04 day, uint04 hour=0, uint04 minute=0, uint04 second=0, bool is_local_time=false)
Constructs a Time object using date and time components.
void setYear(const uint02 &year, bool is_local_time)
Sets the year (1970-2106).
static Time SystemTime()
Retrieves the current system time which is a combination of std::chrono::steady_clock to ensure smoot...
uint01 hour(bool is_local_time) const
Retrieves the hour of the day, 0-23.
uint08 unixTime() const
Converts the timestamp to a UNIX time representation, or seconds since 1970.
void setMonthDay(const uint01 &day, bool is_local_time)
Sets the day of the month (1-31).
void setTimeFromString(const StringView &time_string, bool is_local_time, const StringView &format_string)
Sets the time by converting the timestamp from a string representation.
uint02 millisecond() const
Retrieves the millisecond part of a second, from 0-999.
constexpr uint08 getNanoSeconds() const
Gets the time in nanoseconds since 1970.
fltp08 julianDay(bool is_local_time) const
Julian dates (abbreviated JD) are simply a continuous count of days and fractions since noon Universa...
uint01 monthDay(bool is_local_time) const
Retrieves the day of the month, 1-31.
void setDayOfYear(const uint02 &day, bool is_local_time)
Sets the day of the year (1-365 or 366 on leap years).
uint08 getMilliseconds() const
Gets the timestamp in milliseconds since 1970.
void setTime(const uint08 &time)
Sets the internal timestamp.
uint01 minute(bool is_local_time) const
Retrieves the minute of the hour, from 0-59.
constexpr Time(const uint08 &time)
Constructor initializing the timestamp with a specific value.
Month
Enumerates the months of the year.
void setMillisecond(const uint02 &millisecond)
Sets the millisecond of the second, 0-999.
Time(const StringView &time_string, bool is_local_time, const StringView &format_string)
Constructs a Time from a string representation.
void setMinute(const uint01 &minute, bool is_local_time)
Sets the minute of the hour, 0-59.
uint02 year(bool is_local_time) const
Retrieves the year component of the timestamp.
uint01 second(bool is_local_time) const
Retrieves the second of the minute, from 0-59 (60 if ultra-rare leap second).
constexpr Time()
Default constructor initializing an invalid timestamp.
void setSecond(const uint01 &second, bool is_local_time)
Sets the second of the minute, 0-59.
uint02 yearDay(bool is_local_time) const
Retrieves the day of the year, 1-365(366 on leap year).
Month month(bool is_local_time) const
Retrieves the month component of the timestamp.
void setHour(const uint01 &hour, bool is_local_time)
Sets the hour of the day, 0-23.
The primary namespace for the NDEVR SDK.
constexpr bool operator!=(const Vector< t_dims, t_type > &vec_a, const Vector< t_dims, t_type > &vec_b)
Inequality operator.
uint16_t uint02
-Defines an alias representing a 2 byte, unsigned integer -Can represent exact integer values 0 throu...
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
int64_t sint08
-Defines an alias representing an 8 byte, signed integer -Can represent exact integer values -9223372...
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Information about the object.