C++ Based OPC UA Client/Server/PubSub SDK
1.7.8.584
|
Wrapper class for the UA stack structure OpcUa_DateTime. More...
#include <uadatetime.h>
Public Member Functions | |
UaDateTime () | |
Creates a UaDateTime object initialized with a null value. | |
UaDateTime (const OpcUa_DateTime &) | |
Creates a UaDateTime object initialized with the passed OpcUa_DateTime structure. More... | |
virtual | ~UaDateTime () |
Destroys the UaDateTime object. | |
UaDateTime (const FILETIME &) | |
Creates a UaDateTime object initialized with the passed Windows FILETIME value. More... | |
UaDateTime & | operator= (const FILETIME &) |
Assign a new time using Windows FILETIME value. More... | |
operator FILETIME () const | |
Get the time as Windows FILETIME value. More... | |
UaDateTime (const OpcUa_Int64 &) | |
Creates a UaDateTime object initialized with the passed Int64 value. More... | |
UaDateTime & | operator= (const OpcUa_Int64 &) |
Assign a new time using a OpcUa_Int64 value. More... | |
operator OpcUa_Int64 () const | |
Get the time as Int64 value. More... | |
operator OpcUa_DateTime () const | |
Get the time as OpcUa_DateTime structure. More... | |
bool | operator< (const UaDateTime &other) const |
Less than operator for comparing two date/time values. More... | |
bool | operator> (const UaDateTime &other) const |
Greater than operator for comparing two date/time values. More... | |
bool | operator== (const UaDateTime &other) const |
Equals operator for comparing two date/time values. More... | |
bool | operator!= (const UaDateTime &other) const |
Not Equals operator for comparing two date/time values. More... | |
UaString | toString () const |
Converts the UaDateTime into a UaString. More... | |
UaString | toDateString () const |
Converts the date part of the UaDateTime into a UaString. More... | |
UaString | toTimeString () const |
Converts the time part of the UaDateTime into a UaString. More... | |
time_t | toTime_t () const |
Converts the UaDateTime value to UNIX timestamp format time_t. More... | |
int | msec () const |
Returns the milliseconds part of the UaDateTime object. More... | |
OpcUa_Boolean | isNull () const |
Checks whether UaDateTime is null or not. More... | |
OpcUa_Int32 | daysTo (const UaDateTime &) const |
Returns the days from the own time value to the passed time value. More... | |
OpcUa_Int32 | secsTo (const UaDateTime &) const |
Returns the seconds from the own time value to the passed time value. More... | |
OpcUa_Int64 | msecsTo (const UaDateTime &) const |
Returns the milliseconds from the own time value to the passed time value. More... | |
void | addSecs (int secs) |
Adds the passed number of seconds to the date/time value. More... | |
void | addMilliSecs (int msecs) |
Adds the passed number of milliseconds to the date/time value. More... | |
void | copyTo (OpcUa_DateTime *copy) const |
Copy the internal date/time value into an OpcUa_DateTime structure. | |
void | toVariant (UaVariant &variant) const |
Copies the internal date/time value to a UaVariant. | |
void | toVariant (OpcUa_Variant &variant) const |
Copies the internal date/time value to a OpcUa_Variant structure. | |
void | toDataValue (UaDataValue &dataValue, OpcUa_Boolean updateTimeStamps) const |
Copies the internal date/time value to a UaDataValue. More... | |
void | toDataValue (OpcUa_DataValue &dataValue, OpcUa_Boolean updateTimeStamps) const |
Copies the internal date/time value to a OpcUa_DataValue structure. More... | |
Static Public Member Functions | |
static UaDateTime | now () |
Returns a UaDateTime object representing the current date and time. More... | |
static UaDateTime | fromString (const UaString &) |
Get UaDateTime from string in ISO 8601 format. More... | |
static UaDateTime | fromTime_t (time_t tim) |
Get UaDateTime from time_t. More... | |
Friends | |
UABASE_EXPORT UaDataStream & | operator<< (UaDataStream &, const UaDateTime &) |
Writes the internal date/time value to the stream. | |
UABASE_EXPORT UaDataStream & | operator>> (UaDataStream &, UaDateTime &) |
Reads a date/time value from the stream. | |
Wrapper class for the UA stack structure OpcUa_DateTime.
Helper class for handling the OPC UA built-in data type DateTime. It provides conversion and comparison functions and allows to create a current timestamp.
A DateTime value is a 64-bit signed integer which represents the number of 100 nanosecond intervals since January 1, 1601 (UTC). It is normally represented by the structure OpcUa_DateTime with the two UInt32 members dwLowDateTime and dwHighDateTime. This may be different on special platforms.
Not all platforms will be able to represent the full range of dates and times that can be represented with this built-in data type. For example, the UNIX time_t structure only has a 1 second resolution and cannot represent dates prior to 1970. For this reason, a number of rules shall be applied when dealing with date/time values that exceed the dynamic range of a platform. These rules are:
These rules imply that the earliest and latest times that can be represented on a given platform are invalid date/time values and should be treated that way by applications.
UaDateTime::UaDateTime | ( | const OpcUa_DateTime & | dateTime | ) |
Creates a UaDateTime object initialized with the passed OpcUa_DateTime structure.
dateTime | the OpcUa_DateTime structure used to initialize the UaDateTime object |
UaDateTime::UaDateTime | ( | const FILETIME & | fileTime | ) |
Creates a UaDateTime object initialized with the passed Windows FILETIME value.
This constructor is only available on Windows.
fileTime | The initial date time as FILETIME. |
UaDateTime::UaDateTime | ( | const OpcUa_Int64 & | time | ) |
Creates a UaDateTime object initialized with the passed Int64 value.
time | The time as OpcUa_Int64. |
void UaDateTime::addMilliSecs | ( | int | msecs | ) |
Adds the passed number of milliseconds to the date/time value.
msecs | the number of milliseconds to add. |
void UaDateTime::addSecs | ( | int | secs | ) |
Adds the passed number of seconds to the date/time value.
secs | the number of seconds to add. |
OpcUa_Int32 UaDateTime::daysTo | ( | const UaDateTime & | to | ) | const |
Returns the days from the own time value to the passed time value.
Calculates the days between the value of the UaDateTime object and the passed UaDateTime object. If the passed in time is later than the internal time, the return value is positive. If the passed in value is earlier than the internal time, the returned value is negative.
to | the UaDateTime used to calculate difference in days. |
|
static |
Get UaDateTime from string in ISO 8601 format.
ISO 8601 string format is specified in the following form "YYYY-MM-DDThh:mm:ss" where:
Placeholder | Description |
---|---|
YYYY | indicates the year |
MM | indicates the month |
DD | indicates the day |
T | indicates the start of the required time section |
hh | indicates the hour |
mm | indicates the minute |
ss | indicates the second |
Example: 2002-05-30T09:00:00
Time Zones:
To specify a time zone, you can either enter a dateTime in UTC time by adding a "Z" behind the time: 2012-05-30T09:30:10Z
or you can specify an offset from the UTC time by adding a positive or negative time behind the time: 2012-05-30T09:30:10-06:00 or 2012-05-30T09:30:10+06:00
sTime | the string to convert. |
|
static |
Get UaDateTime from time_t.
tim | the time_t struct used to initialize the UaDateTime object |
OpcUa_Boolean UaDateTime::isNull | ( | ) | const |
Checks whether UaDateTime is null or not.
int UaDateTime::msec | ( | ) | const |
Returns the milliseconds part of the UaDateTime object.
OpcUa_Int64 UaDateTime::msecsTo | ( | const UaDateTime & | to | ) | const |
Returns the milliseconds from the own time value to the passed time value.
Calculates the milliseconds between the value of the UaDateTime object and the passed UaDateTime object. If the passed in time is later than the internal time, the return value is positive. If the passed in value is earlier than the internal time, the returned value is negative.
to | the UaDateTime used to calculate the difference in milliseconds. |
|
static |
Returns a UaDateTime object representing the current date and time.
UaDateTime::operator FILETIME | ( | ) | const |
Get the time as Windows FILETIME value.
This operator is only available on Windows.
UaDateTime::operator OpcUa_DateTime | ( | ) | const |
Get the time as OpcUa_DateTime structure.
UaDateTime::operator OpcUa_Int64 | ( | ) | const |
Get the time as Int64 value.
bool UaDateTime::operator!= | ( | const UaDateTime & | other | ) | const |
Not Equals operator for comparing two date/time values.
other | the UaDateTime to compare. |
bool UaDateTime::operator< | ( | const UaDateTime & | other | ) | const |
Less than operator for comparing two date/time values.
other | the UaDateTime to compare. |
UaDateTime & UaDateTime::operator= | ( | const FILETIME & | fileTime | ) |
Assign a new time using Windows FILETIME value.
This operator is only available on Windows.
fileTime | The time as FILETIME. |
UaDateTime & UaDateTime::operator= | ( | const OpcUa_Int64 & | time | ) |
Assign a new time using a OpcUa_Int64 value.
time | The time as OpcUa_Int64. |
bool UaDateTime::operator== | ( | const UaDateTime & | other | ) | const |
Equals operator for comparing two date/time values.
other | the UaDateTime to compare. |
bool UaDateTime::operator> | ( | const UaDateTime & | other | ) | const |
Greater than operator for comparing two date/time values.
other | the UaDateTime to compare. |
OpcUa_Int32 UaDateTime::secsTo | ( | const UaDateTime & | to | ) | const |
Returns the seconds from the own time value to the passed time value.
Calculates the seconds between the value of the UaDateTime object and the passed UaDateTime object. If the passed in time is later than the internal time, the return value is positive. If the passed in value is earlier than the internal time, the returned value is negative.
to | the UaDateTime used to calculate difference in seconds. |
void UaDateTime::toDataValue | ( | UaDataValue & | dataValue, |
OpcUa_Boolean | updateTimeStamps | ||
) | const |
Copies the internal date/time value to a UaDataValue.
The value is set with the date/time and the status is set to OpcUa_Good.
dataValue | the UaDataValue to update. |
updateTimeStamps | If OpcUa_True, the timestamps of the DataValue are set to the current time. Otherwise the timestamps are not changed. |
void UaDateTime::toDataValue | ( | OpcUa_DataValue & | dataValue, |
OpcUa_Boolean | updateTimeStamps | ||
) | const |
Copies the internal date/time value to a OpcUa_DataValue structure.
The value is set with the date/time and the status is set to OpcUa_Good.
dataValue | the UaDataValue to update. |
updateTimeStamps | If OpcUa_True, the timestamps of the DataValue are set to the current time. Otherwise the timestamps are initialized to null. |
UaString UaDateTime::toDateString | ( | ) | const |
Converts the date part of the UaDateTime into a UaString.
UaString UaDateTime::toString | ( | ) | const |
Converts the UaDateTime into a UaString.
time_t UaDateTime::toTime_t | ( | ) | const |
Converts the UaDateTime value to UNIX timestamp format time_t.
The time range is different as well and goes from 1970-01-01 till 2038-01-18 on 32 bit systems.
UaString UaDateTime::toTimeString | ( | ) | const |
Converts the time part of the UaDateTime into a UaString.