1#include <Foundation/FoundationInternal.h>
2PL_FOUNDATION_INTERNAL_HEADER
4#include <Foundation/Time/Timestamp.h>
12 gettimeofday(¤tTime,
nullptr);
17bool operator!=(
const tm& lhs,
const tm& rhs)
19 if (lhs.tm_isdst == rhs.tm_isdst)
21 return !((lhs.tm_sec == rhs.tm_sec) && (lhs.tm_min == rhs.tm_min) && (lhs.tm_hour == rhs.tm_hour) && (lhs.tm_mday == rhs.tm_mday) &&
22 (lhs.tm_mon == rhs.tm_mon) && (lhs.tm_year == rhs.tm_year) && (lhs.tm_isdst == rhs.tm_isdst));
39 timeinfo.tm_sec = m_uiSecond;
40 timeinfo.tm_min = m_uiMinute;
41 timeinfo.tm_hour = m_uiHour;
42 timeinfo.tm_mday = m_uiDay;
43 timeinfo.tm_wday = m_uiDayOfWeek;
44 timeinfo.tm_mon = m_uiMonth - 1;
45 timeinfo.tm_year = m_iYear - 1900;
46 timeinfo.tm_isdst = 0;
47 timeinfo.tm_zone =
"GMT";
49 tm timeinfoCopy = timeinfo;
51 time_t iTimeStamp = mktime(&timeinfo);
53 if (iTimeStamp == (time_t)-1 || timeinfoCopy != timeinfo)
56 iTimeStamp += timeinfo.tm_gmtoff;
58 if (timeinfo.tm_isdst == 1)
67 if (gmtime_r(&iTime, &timeinfo) ==
nullptr)
70 m_iYear = timeinfo.tm_year + 1900;
71 m_uiMonth = timeinfo.tm_mon + 1;
72 m_uiDay = timeinfo.tm_mday;
73 m_uiDayOfWeek = timeinfo.tm_wday;
74 m_uiHour = timeinfo.tm_hour;
75 m_uiMinute = timeinfo.tm_min;
76 m_uiSecond = timeinfo.tm_sec;
plResult SetFromTimestamp(plTimestamp timestamp)
Sets this instance to the given timestamp.
Definition Timestamp_Posix.h:63
const plTimestamp GetTimestamp() const
Converts this instance' values into a plTimestamp.
Definition Timestamp_Posix.h:35
The timestamp class encapsulates a date in time as microseconds since Unix epoch.
Definition Timestamp.h:23
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
static plTimestamp MakeInvalid()
Returns an invalid timestamp.
Definition Timestamp.h:47
static const plTimestamp CurrentTimestamp()
Returns the current timestamp. Returned value will always be valid.
Definition Timestamp_Posix.h:9
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54
@ Second
SI-unit of time (base unit)
Definition Timestamp.h:13
@ Microsecond
SI-unit of time (10^-6 second)
Definition Timestamp.h:11