8#include "Arp/System/Core/PrimitiveTypes.hpp"
12#ifndef ARP_INSIDE_ARP_H
13 #error Never include 'DateTime.hpp' directly, just include 'Arp.h'
58 ARP_DEPRECATED(
"Use overload with DateTimeKind parameter instead.")
100 DateTime(
int year,
int month,
int day,
int hour,
int minute,
int second,
int millisecond,
int microsecond);
133 DateTime(
int year,
int month,
int day,
int hour,
int minute,
int second,
int millisecond,
int microsecond,
DateTimeKind kind);
148 bool operator==(const
DateTime& arg)const;
152 bool operator!=(const
DateTime& arg)const;
156 bool operator>(const
DateTime& arg)const;
160 bool operator<(const
DateTime& arg)const;
164 bool operator>=(const
DateTime& arg)const;
168 bool operator<=(const
DateTime& arg)const;
286 friend
std::ostream& operator<<(
std::ostream& os, const
DateTime& dateTime);
287 friend
std::istream& operator>>(
std::istream& is,
DateTime& dateTime);
290 int GetDatePart(
int part)const;
293 static
int64 DateToTicks(
int year,
int month,
int day);
294 static
int64 TimeToTicks(
int hour,
int minute,
int second);
295 static
int64 TimeToTicks(
int hour,
int minute,
int second,
int millisecond,
int microsecond);
305 static const
int kindShift = 62;
306 static const
uint64 kindMask = 3ULL << kindShift;
307 static const
uint64 ticksMask = ~kindMask;
310 static const
int64 ticksPerMicrosecond = 10;
311 static const
int64 ticksPerMillisecond = ticksPerMicrosecond * 1000;
312 static const
int64 ticksPerSecond = ticksPerMillisecond * 1000;
313 static const
int64 ticksPerMinute = ticksPerSecond * 60;
314 static const
int64 ticksPerHour = ticksPerMinute * 60;
315 static const
int64 ticksPerDay = ticksPerHour * 24;
318 static const
int daysPerYear = 365;
320 static const
int daysPer4Years = daysPerYear * 4 + 1;
322 static const
int daysPer100Years = daysPer4Years * 25 - 1;
324 static const
int daysPer400Years = daysPer100Years * 4 + 1;
327 static const
int daysTo1970 = daysPer400Years * 4 + daysPer100Years * 3 + daysPer4Years * 17 + daysPerYear;
329 static const
int daysTo1601 = daysPer400Years * 4;
331 static const
int daysTo10000 = daysPer400Years * 25 - 366;
333 static const
int daysToMonth365[];
334 static const
int daysToMonth366[];
336 static const
int datePartYear = 0;
337 static const
int datePartMonth = 2;
338 static const
int datePartDayOfYear = 1;
339 static const
int datePartDay = 3;
342 static const
int64 unix0Ticks = daysTo1970 * ticksPerDay;
343 static const
int64 opcua0Ticks = daysTo1601 * ticksPerDay;
393 return (
int64)(this->data & ticksMask);
The class contains date and time informations.
Definition: DateTime.hpp:46
uint64 ToBinary(void) const
Converts this instance to a binary representation.
static DateTime FromIso8601String(const String &value)
Creates a DateTime from the as argument passed ISO8601 string.
int64 ToUnixTimeMicroseconds(void) const
Converts this instance to unix time (UTC) in microseconds.
static const int64 MaxTicks
The maximal tick count.
Definition: DateTime.hpp:351
int GetDay(void) const
Gets the day of the month component of the date represented by this instance.
int GetMillisecond(void) const
Gets the millisecond component of the date represented by this instance.
static DateTime FromOpcUaTime(int64 opcUaTime)
Creates a DateTime from the argument passed in OpcUA time.
static const int64 MinTicks
The minimal tick count.
Definition: DateTime.hpp:348
static DateTime FromUnixTimeMicroseconds(int64 microseconds)
Creates a DateTime from the as argument passed unix time in microseconds.
String ToIso8601String(void) const
Converts this instance to an ISO8601 string .
int GetYear(void) const
Gets the year component of the date represented by this instance.
static DateTime GetUtcNow(void)
Gets the current time as DateTime, expressed as the UTC time.
int64 ToOpcUaTime(void) const
Converts this instance to OPC time (UTC).
int GetMinute(void) const
Gets the minute component of the date represented by this instance.
int GetHour(void) const
Gets the hour component of the date represented by this instance.
static DateTime Now(void)
Deprecated! Gets the current time as DateTime, expressed as the UTC time.
friend std::istream & operator>>(std::istream &is, DateTime &dateTime)
The istream operator is used for string parsing and expects the ISO-8601 format.
Definition: DateTime.hpp:414
static bool IsLeapYear(int year)
Returns an indication whether the specified year is a leap year.
time_t ToUnixTime(void) const
Converts this instance to unix time (UTC).
static DateTime FromUnixTime(time_t unixTime)
Creates a DateTime from the as argument passed unix time.
uint64 ToUnixMicrosecondTicks(void) const
Deprecated! Converts this instance to unix time (UTC) in microseconds.
static DateTime FromBinary(uint64 data)
Creates a DateTime from the as argument passed binary representation.
int GetSecond(void) const
Gets the second component of the date represented by this instance.
bool IsEmpty(void) const
Checks if this instance represents a valid date.
friend std::ostream & operator<<(std::ostream &os, const DateTime &dateTime)
The ostream operator is used for logging and string formatting and formats the DateTime value in ISO-...
Definition: DateTime.hpp:407
int GetMonth(void) const
Gets the month component of the date represented by this instance.
int GetMicrosecond(void) const
Gets the microsecond component of the date represented by this instance.
bool operator!=(const DateTime &arg) const
Compares the ticks of this instance to arg .
Definition: DateTime.hpp:366
std::uint64_t uint64
The Arp unsigned integer type of 8 byte size.
Definition: PrimitiveTypes.hpp:40
int64 GetTicks(void) const
Gets the number of ticks that represent the date and time of this instance.
Definition: DateTime.hpp:391
bool operator<(const DateTime &arg) const
Compares the ticks of this instance to arg .
Definition: DateTime.hpp:376
bool operator==(const DateTime &arg) const
Compares the ticks of this instance to arg .
Definition: DateTime.hpp:361
DateTimeKind
Specifies whether a DateTime object represents a local time, a Coordinated Universal Time (UTC),...
Definition: DateTime.hpp:27
bool operator>(const DateTime &arg) const
Compares the ticks of this instance to arg .
Definition: DateTime.hpp:371
bool operator>=(const DateTime &arg) const
Compares the ticks of this instance to arg .
Definition: DateTime.hpp:381
std::int64_t int64
The Arp integer type of 8 byte size.
Definition: PrimitiveTypes.hpp:42
bool operator<=(const DateTime &arg) const
Compares the ticks of this instance to arg .
Definition: DateTime.hpp:386
DateTimeKind GetKind(void) const
Gets a value that indicates whether the time represented by this instance is based on local time,...
Definition: DateTime.hpp:396
static DateTime FromUnixMicrosecondTicks(uint64 microseconds)
Deprecated! Creates a DateTime from the as argument passed unix time in microseconds.
Definition: DateTime.hpp:401
DateTime(void)
Constructs an zero'ed DateTime instance.
Definition: DateTime.hpp:356
Root namespace for the PLCnext API
class ARP_DEPRECATED("Use Arp::Enum<T> instead.") EnumStrings
Deprecated! The class implements an adapter for enums to define the string literals of the enum entri...
Definition: EnumStrings.hxx:38
Namespace of the C++ standard library