High Performance OPC UA Server SDK
1.7.1.383
|
This Built-in DataType defines a Gregorian calendar date. More...
Typedefs | |
typedef uint64_t | ua_datetime |
Opaque ua_datetime. More... | |
Functions | |
BASE_EXPORT void | ua_datetime_init (ua_datetime *dt) |
Initialize ua_datetime with the earliest possible value. | |
BASE_EXPORT void | ua_datetime_clear (ua_datetime *dt) |
Clear ua_datetime and set to the earliest possible value. | |
BASE_EXPORT int | ua_datetime_compare (const ua_datetime *a, const ua_datetime *b) |
Compare two ua_datetimes. More... | |
BASE_EXPORT int | ua_datetime_now (ua_datetime *dt) |
Get the current time as ua_datetime. More... | |
static void | ua_datetime_copy (ua_datetime *dst, const ua_datetime *src) |
BASE_EXPORT time_t | ua_datetime_to_time_t (const ua_datetime *dt) |
Convert ua_datetime to time_t. More... | |
BASE_EXPORT uint64_t | ua_datetime_to_time_t64 (const ua_datetime *dt) |
Convert ua_datetime to time_t. More... | |
BASE_EXPORT uint64_t | ua_datetime_msecs_since_epoch (const ua_datetime *dt) |
Returns the milliseconds since UNIX epoch (1970-01-01T00:00:00Z). More... | |
BASE_EXPORT void | ua_datetime_from_time_t (ua_datetime *dt, const time_t *t) |
Convert time_t to ua_datetime. More... | |
BASE_EXPORT int | ua_datetime_to_string (const ua_datetime *dt, struct ua_string *dst) |
Converts the given UA datetime parameter dt into an UA string. More... | |
BASE_EXPORT int | ua_datetime_snprintf (char *dst, size_t size, const ua_datetime *dt) |
Converts the given UA datetime parameter dt into a string. More... | |
BASE_EXPORT int | ua_datetime_from_string (ua_datetime *dt, const struct ua_string *src) |
Parses the given date string and creates a UA datetime from it. More... | |
This Built-in DataType defines a Gregorian calendar date.
It is 64-bit signed integer representing the number of 100 nanoseconds intervals since 1601-01-01 00:00:00. This is the same as the WIN32 FILETIME type.
typedef uint64_t ua_datetime |
Opaque ua_datetime.
Opaque means that you cannot make any assumption if the type's contents. So don't access any fields directly. Always used the provided accessor functions.
BASE_EXPORT int ua_datetime_compare | ( | const ua_datetime * | a, |
const ua_datetime * | b | ||
) |
Compare two ua_datetimes.
BASE_EXPORT int ua_datetime_from_string | ( | ua_datetime * | dt, |
const struct ua_string * | src | ||
) |
Parses the given date string and creates a UA datetime from it.
This function expects a date string in ISO8601 format: "YYYY-MM-DDThh:mm:ss[.nnn]Z". This is the same format as used in ua_datetime_snprintf and ua_datetime_to_string, so this works as reverse operation of ua_datetime_to_string. The milliseconds part nnn is optional. Currently only Zulu time is supported.
dt | UA DateTime which receives the resulting date value |
src | Date string to parse. |
BASE_EXPORT void ua_datetime_from_time_t | ( | ua_datetime * | dt, |
const time_t * | t | ||
) |
Convert time_t to ua_datetime.
Note the a time_t (UNIX epoch) has a different time range then UA DateTime (Windows FILETIME). The UNIX epoch starts at 1970, wherees FILETIME starts at 1601.
In UA some specific DateTime values have a special meaning. For this reason the following exceptions exist:
UA specification 6 section 5.2.2.5 DateTime:
A date/time value is encoded as 0 if either 1) The value is equal to or earlier than 1601-01-01 12:00AM UTC. 2) The value is the earliest date that can be represented with the DevelopmentPlatform’s encoding.
A date/time is encoded as the maximum value for an Int64 if either 3) The value is equal to or greater than 9999-12-31 11:59:59PM UTC, 4) The value is the latest date that can be represented with the DevelopmentPlatform’s encoding.
dt | Result of the conversion. |
t | Value to convert. |
BASE_EXPORT uint64_t ua_datetime_msecs_since_epoch | ( | const ua_datetime * | dt | ) |
Returns the milliseconds since UNIX epoch (1970-01-01T00:00:00Z).
dt | The UA datetime value to convert. |
BASE_EXPORT int ua_datetime_now | ( | ua_datetime * | dt | ) |
Get the current time as ua_datetime.
dt | Pointer to ua_datetime to write the current time to. |
BASE_EXPORT int ua_datetime_snprintf | ( | char * | dst, |
size_t | size, | ||
const ua_datetime * | dt | ||
) |
Converts the given UA datetime parameter dt
into a string.
This functions prints the date string into the preallocated buffer dst
. The date format is "YYYY-MM-DDThh:mm:ss.nnnZ", also known as ISO8601. The fractional part at the end is optional (n) and has an accuracy of up to 7 digits to be able to represent the full UA DateTime resolution (100ns intervals). Examples: 2020-02-04T00:00:00Z 2017-05-26T15:42:00.1934169Z 2020-02-12T13:22:47.785Z
dst | Pointer of preallocated string buffer. |
size | Length of dst in bytes. |
dt | UA DateTime input parameter. |
BASE_EXPORT int ua_datetime_to_string | ( | const ua_datetime * | dt, |
struct ua_string * | dst | ||
) |
Converts the given UA datetime parameter dt
into an UA string.
This function uses ua_datetime_snprintf to write the formatted date string into the UA string buffer. The parameter dst
, can be an uninitialized variable. It will be initialized using ua_string_allocate internally. You must call ua_string_clear to free these resources.
Example:
dt | The UA datetime value |
dst | The UA string which receives the result. |
BASE_EXPORT time_t ua_datetime_to_time_t | ( | const ua_datetime * | dt | ) |
Convert ua_datetime to time_t.
Note the a time_t (UNIX epoch) has a different time range then UA DateTime (Windows FILETIME). The UNIX epoch starts at 1970, wherees FILETIME starts at 1601.
In UA some specific DateTime values have a special meaning. For this reason the following exceptions exist:
dt | Value to convert. |
BASE_EXPORT uint64_t ua_datetime_to_time_t64 | ( | const ua_datetime * | dt | ) |
Convert ua_datetime to time_t.
This allows to create 64 bit time_t values on systems where time_t is defined as a 32bit type. This is e.g. the case on 32 bit Linux systems, whereas on 64 bit Linux this type is also 64 bit and does not have the Y2038 problem.
In UA some specific DateTime values have a special meaning. For this reason the following exceptions exist:
dt | Value to convert. |