Plasma Engine  2.0
Loading...
Searching...
No Matches
Timestamp_inl.h
1#pragma once
2
3#include <Foundation/Basics.h>
4#include <Foundation/Math/Math.h>
5
6inline plTimestamp::plTimestamp() = default;
7
8inline bool plTimestamp::IsValid() const
9{
10 return m_iTimestamp != PL_INVALID_TIME_STAMP;
11}
12
13inline void plTimestamp::operator+=(const plTime& timeSpan)
14{
15 PL_ASSERT_DEBUG(IsValid(), "Arithmetics on invalid time stamps are not allowed!");
16 m_iTimestamp += (plInt64)timeSpan.GetMicroseconds();
17}
18
19inline void plTimestamp::operator-=(const plTime& timeSpan)
20{
21 PL_ASSERT_DEBUG(IsValid(), "Arithmetics on invalid time stamps are not allowed!");
22 m_iTimestamp -= (plInt64)timeSpan.GetMicroseconds();
23}
24
25inline const plTime plTimestamp::operator-(const plTimestamp& other) const
26{
27 PL_ASSERT_DEBUG(IsValid(), "Arithmetics on invalid time stamps are not allowed!");
28 PL_ASSERT_DEBUG(other.IsValid(), "Arithmetics on invalid time stamps are not allowed!");
29 return plTime::MakeFromMicroseconds((double)(m_iTimestamp - other.m_iTimestamp));
30}
31
32inline const plTimestamp plTimestamp::operator+(const plTime& timeSpan) const
33{
34 PL_ASSERT_DEBUG(IsValid(), "Arithmetics on invalid time stamps are not allowed!");
35 return plTimestamp::MakeFromInt(m_iTimestamp + (plInt64)timeSpan.GetMicroseconds(), plSIUnitOfTime::Microsecond);
36}
37
38inline const plTimestamp plTimestamp::operator-(const plTime& timeSpan) const
39{
40 PL_ASSERT_DEBUG(IsValid(), "Arithmetics on invalid time stamps are not allowed!");
41 return plTimestamp::MakeFromInt(m_iTimestamp - (plInt64)timeSpan.GetMicroseconds(), plSIUnitOfTime::Microsecond);
42}
43
44inline const plTimestamp operator+(const plTime& timeSpan, const plTimestamp& timestamp)
45{
46 PL_ASSERT_DEBUG(timestamp.IsValid(), "Arithmetics on invalid time stamps are not allowed!");
48}
49
50
51
52inline plUInt32 plDateTime::GetYear() const
53{
54 return m_iYear;
55}
56
57inline void plDateTime::SetYear(plInt16 iYear)
58{
59 m_iYear = iYear;
60}
61
62inline plUInt8 plDateTime::GetMonth() const
63{
64 return m_uiMonth;
65}
66
67inline void plDateTime::SetMonth(plUInt8 uiMonth)
68{
69 PL_ASSERT_DEBUG(uiMonth >= 1 && uiMonth <= 12, "Invalid month value");
70 m_uiMonth = uiMonth;
71}
72
73inline plUInt8 plDateTime::GetDay() const
74{
75 return m_uiDay;
76}
77
78inline void plDateTime::SetDay(plUInt8 uiDay)
79{
80 PL_ASSERT_DEBUG(uiDay >= 1 && uiDay <= 31, "Invalid day value");
81 m_uiDay = uiDay;
82}
83
84inline plUInt8 plDateTime::GetDayOfWeek() const
85{
86 return m_uiDayOfWeek;
87}
88
89inline void plDateTime::SetDayOfWeek(plUInt8 uiDayOfWeek)
90{
91 PL_ASSERT_DEBUG(uiDayOfWeek <= 6, "Invalid day of week value");
92 m_uiDayOfWeek = uiDayOfWeek;
93}
94
95inline plUInt8 plDateTime::GetHour() const
96{
97 return m_uiHour;
98}
99
100inline void plDateTime::SetHour(plUInt8 uiHour)
101{
102 PL_ASSERT_DEBUG(uiHour <= 23, "Invalid hour value");
103 m_uiHour = uiHour;
104}
105
106inline plUInt8 plDateTime::GetMinute() const
107{
108 return m_uiMinute;
109}
110
111inline void plDateTime::SetMinute(plUInt8 uiMinute)
112{
113 PL_ASSERT_DEBUG(uiMinute <= 59, "Invalid minute value");
114 m_uiMinute = uiMinute;
115}
116
117inline plUInt8 plDateTime::GetSecond() const
118{
119 return m_uiSecond;
120}
121
122inline void plDateTime::SetSecond(plUInt8 uiSecond)
123{
124 PL_ASSERT_DEBUG(uiSecond <= 59, "Invalid second value");
125 m_uiSecond = uiSecond;
126}
127
128inline plUInt32 plDateTime::GetMicroseconds() const
129{
130 return m_uiMicroseconds;
131}
132
133inline void plDateTime::SetMicroseconds(plUInt32 uiMicroSeconds)
134{
135 PL_ASSERT_DEBUG(uiMicroSeconds <= 999999u, "Invalid micro-second value");
136 m_uiMicroseconds = uiMicroSeconds;
137}
void SetHour(plUInt8 uiHour)
Sets the hour to the given value. Asserts that the value is in the valid range [0,...
Definition Timestamp_inl.h:100
void SetYear(plInt16 iYear)
Sets the year to the given value.
Definition Timestamp_inl.h:57
plUInt8 GetDayOfWeek() const
Returns the currently set day of week.
Definition Timestamp_inl.h:84
void SetMicroseconds(plUInt32 uiMicroSeconds)
Sets the microseconds to the given value. Asserts that the value is in the valid range [0,...
Definition Timestamp_inl.h:133
plUInt8 GetMinute() const
Returns the currently set minute.
Definition Timestamp_inl.h:106
void SetDayOfWeek(plUInt8 uiDayOfWeek)
Sets the day of week to the given value. Asserts that the value is in the valid range [0,...
Definition Timestamp_inl.h:89
plUInt32 GetMicroseconds() const
Returns the currently set microseconds.
Definition Timestamp_inl.h:128
plUInt8 GetDay() const
Returns the currently set day.
Definition Timestamp_inl.h:73
plUInt8 GetSecond() const
Returns the currently set second.
Definition Timestamp_inl.h:117
plUInt8 GetMonth() const
Returns the currently set month.
Definition Timestamp_inl.h:62
void SetDay(plUInt8 uiDay)
Sets the day to the given value. Asserts that the value is in the valid range [1, 31].
Definition Timestamp_inl.h:78
void SetMonth(plUInt8 uiMonth)
Sets the month to the given value. Asserts that the value is in the valid range [1,...
Definition Timestamp_inl.h:67
plUInt32 GetYear() const
Returns the currently set year.
Definition Timestamp_inl.h:52
void SetMinute(plUInt8 uiMinute)
Sets the minute to the given value. Asserts that the value is in the valid range [0,...
Definition Timestamp_inl.h:111
plUInt8 GetHour() const
Returns the currently set hour.
Definition Timestamp_inl.h:95
void SetSecond(plUInt8 uiSecond)
Sets the second to the given value. Asserts that the value is in the valid range [0,...
Definition Timestamp_inl.h:122
The timestamp class encapsulates a date in time as microseconds since Unix epoch.
Definition Timestamp.h:23
void operator-=(const plTime &timeSpan)
Subtracts the time value of "timeSpan" from this date value.
Definition Timestamp_inl.h:19
bool IsValid() const
Returns whether the timestamp is valid.
Definition Timestamp_inl.h:8
void operator+=(const plTime &timeSpan)
Adds the time value of "timeSpan" to this data value.
Definition Timestamp_inl.h:13
plTimestamp()
Creates an invalidated timestamp.
const plTimestamp operator+(const plTime &timeSpan) const
Returns a timestamp that is "timeSpan" further into the future from this timestamp.
Definition Timestamp_inl.h:32
plInt64 GetInt64(plSIUnitOfTime::Enum unitOfTime) const
Returns the number of 'unitOfTime' since Unix epoch.
Definition Timestamp.cpp:17
static plTimestamp MakeFromInt(plInt64 iTimeValue, plSIUnitOfTime::Enum unitOfTime)
Returns a timestamp initialized from 'iTimeValue' in 'unitOfTime' since Unix epoch.
Definition Timestamp.cpp:36
const plTime operator-(const plTimestamp &other) const
Returns the time span between this timestamp and "other".
Definition Timestamp_inl.h:25
@ Microsecond
SI-unit of time (10^-6 second)
Definition Timestamp.h:11
The time class encapsulates a double value storing the time in seconds.
Definition Time.h:12
constexpr double GetMicroseconds() const
Returns the microseconds value.
Definition Time_inl.h:20
PL_ALWAYS_INLINE static constexpr plTime MakeFromMicroseconds(double fMicroseconds)
Creates an instance of plTime that was initialized from microseconds.
Definition Time.h:22