7#include "Arp/System/Core/PrimitiveTypes.hpp"
11#ifndef ARP_INSIDE_ARP_H
12 #error Never include 'DateTime.hpp' directly, just include 'Arp.h'
231 friend
std::ostream& operator<<(
std::ostream& os, const
DateTime& dateTime);
232 friend
std::istream& operator>>(
std::istream& is,
DateTime& dateTime);
235 int GetDatePart(
int part)const;
238 static
int64 DateToTicks(
int year,
int month,
int day);
239 static
int64 TimeToTicks(
int hour,
int minute,
int second);
240 static
int64 TimeToTicks(
int hour,
int minute,
int second,
int millisecond,
int microsecond);
250 static const
int kindShift = 62;
251 static const
uint64 kindMask = 3ULL << kindShift;
252 static const
uint64 ticksMask = ~kindMask;
255 static const
int64 ticksPerMicrosecond = 10;
256 static const
int64 ticksPerMillisecond = ticksPerMicrosecond * 1000;
257 static const
int64 ticksPerSecond = ticksPerMillisecond * 1000;
258 static const
int64 ticksPerMinute = ticksPerSecond * 60;
259 static const
int64 ticksPerHour = ticksPerMinute * 60;
260 static const
int64 ticksPerDay = ticksPerHour * 24;
263 static const
int daysPerYear = 365;
265 static const
int daysPer4Years = daysPerYear * 4 + 1;
267 static const
int daysPer100Years = daysPer4Years * 25 - 1;
269 static const
int daysPer400Years = daysPer100Years * 4 + 1;
272 static const
int daysTo1970 = daysPer400Years * 4 + daysPer100Years * 3 + daysPer4Years * 17 + daysPerYear;
274 static const
int daysTo1601 = daysPer400Years * 4;
276 static const
int daysTo10000 = daysPer400Years * 25 - 366;
278 static const
int daysToMonth365[];
279 static const
int daysToMonth366[];
281 static const
int datePartYear = 0;
282 static const
int datePartMonth = 2;
283 static const
int datePartDayOfYear = 1;
284 static const
int datePartDay = 3;
287 static const
int64 unix0Ticks = daysTo1970 * ticksPerDay;
288 static const
int64 opcua0Ticks = daysTo1601 * ticksPerDay;
338 return (
int64)(this->data & ticksMask);
The class contains date and time informations.
Definition: DateTime.hpp:45
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:296
int GetDay(void) const
Gets the day of the month component of the date represented by this instance.
DateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int microsecond, DateTimeKind kind=DateTimeKind::Unspecified)
Initializes a new instance of the T:System.DateTime structure to the specified year,...
~DateTime(void)=default
Destructs this instance and frees all resources.
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.
DateTime & operator=(const DateTime &arg)=default
The default assignment operator.
static const int64 MinTicks
The minimal tick count.
Definition: DateTime.hpp:293
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.
DateTime(int64 ticks, DateTimeKind kind=DateTimeKind::Unspecified)
Constructs an DateTime instance.
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)
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:359
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
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.
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:352
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.
DateTime(const DateTime &arg)=default
The default copy constructor.
bool operator!=(const DateTime &arg) const
Compares the ticks of this instance to arg .
Definition: DateTime.hpp:311
std::uint64_t uint64
The Arp unsigned integer type of 8 byte size.
Definition: PrimitiveTypes.hpp:39
int64 GetTicks(void) const
Gets the number of ticks that represent the date and time of this instance.
Definition: DateTime.hpp:336
bool operator<(const DateTime &arg) const
Compares the ticks of this instance to arg .
Definition: DateTime.hpp:321
bool operator==(const DateTime &arg) const
Compares the ticks of this instance to arg .
Definition: DateTime.hpp:306
DateTimeKind
Specifies whether a DateTime object represents a local time, a Coordinated Universal Time (UTC),...
Definition: DateTime.hpp:26
bool operator>(const DateTime &arg) const
Compares the ticks of this instance to arg .
Definition: DateTime.hpp:316
bool operator>=(const DateTime &arg) const
Compares the ticks of this instance to arg .
Definition: DateTime.hpp:326
std::int64_t int64
The Arp integer type of 8 byte size.
Definition: PrimitiveTypes.hpp:41
bool operator<=(const DateTime &arg) const
Compares the ticks of this instance to arg .
Definition: DateTime.hpp:331
DateTimeKind GetKind(void) const
Gets a value that indicates whether the time represented by this instance is based on local time,...
Definition: DateTime.hpp:341
static DateTime FromUnixMicrosecondTicks(uint64 microseconds)
Creates a DateTime from the as argument passed unix time in microseconds.
Definition: DateTime.hpp:346
DateTime(void)
Constructs an zero'ed DateTime instance.
Definition: DateTime.hpp:301
@ Unspecified
Kind of time in not specified
Root namespace for the PLCnext API
class ARP_DEPRECATED("Use Arp::Enum<T> instead.") EnumStrings
The class implements an adapter for enums to define the string literals of the enum entries.
Definition: EnumStrings.hxx:38
Namespace of the C++ standard library