This Built-in DataType defines a Gregorian calendar date.
More...
|
#define | ua_datetime_copy(dst, src) *(dst) = *(src) |
|
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.
- See also
- util_utctime
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.
Compare two ua_datetimes.
- Returns
- Zero if the ua_datetimes are the same.
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.
- Parameters
-
dt | UA DateTime which receives the resulting date value |
src | Date string to parse. |
- Returns
- Zero on success. UA_EBAD if the operation fails.
void ua_datetime_from_time_t |
( |
ua_datetime * |
dt, |
|
|
const time_t * |
t |
|
) |
| |
Convert time_t to ua_datetime.
- Parameters
-
dt | Result of the conversion. |
t | Value to convert. |
Get the current time as ua_datetime.
- Parameters
-
dt | Pointer to ua_datetime to write the current time to. |
- Returns
- Zero on success or errorcode on failure.
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.
- Parameters
-
dst | Pointer of preallocated string buffer. |
size | Length of dst in bytes. |
dt | UA DateTime input parameter. |
- Returns
- Zero on success. UA_EBADTRUNCATED if the provided buffer was too short.
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:
4 if (ua_datetime_now(&dt) == 0) {
5 ua_datetime_to_string(&dt, &date);
6 printf("now = %s\n", ua_string_const_data(&date));
7 ua_string_clear(&date);
- Parameters
-
dt | The UA datetime value |
dst | The UA string which receives the result. |
- Returns
- Zero on success, a negative error code on failure.
Convert ua_datetime to time_t.
- Parameters
-
- Returns
- Result of the conversion.