How can I create a node/tree to hold a datetime of an arbitrary value?What C/C++ data type would I pass to an append method?

How can I create a node/tree to hold a datetime of an arbitrary value?What C/C++ data type would I pass to an append method?

book

Article ID: KB0092136

calendar_today

Updated On:

Products Versions
TIBCO Adapter SDK -
Not Applicable -

Description

Resolution:
It is not recommended to build a datetime object by appending to MTree directly. The easiest way to send M_DATETIME is to use SDK MetaData class MDateTime in an MInstance. There is a pair of example programs sdktimeclnt and sdktimesrvr (&ltSDK_ROOT/examples/cpp/sdktimesrvr) that demonstrates how to use the MDateTime class.

The MDateTime class also provides a constructor to build a DateTime instance from a given datetime string. See SDK C++ Manual for more information.

To just send an MTree with M_DATETIME is not as straightforward. M_DATETIME is a direct mapping to RVMSG type RVMSG_DATETIME.  

Please refer to RV documents on how RV supports the DateTime type, which is partially pasted below.

"Rendezvous DateTime format encodes the time with microsecond accuracy. The total time range is approximately 17432 years on each side of the epoch (midnight, zero seconds into January 1, 1970)."  

This means to create a MNode* of M_DATETIME, you will need to create a tibrvMsgDatetime value with a 64-bit and 32-bit integer variables and set each integer value accordingly:

typedef struct
{
    tibrv_i64     sec;
    tibrv_u32     nsec;
} tibrvMsgDateTime;

tibrvMsgDateTime myTime;
time_t currtime; // time_t is same as long
time( &currtime);
myTime.sec = currtime; // only using the seconds
// myTime.nsec = // value is in nanosecond, but sends only millisecond, so value to set here is msec*1000

MNode datetime("myDateTime", M_DATETIME,sizeof(tibrvMsgDateTime), (void*) &myTime);

MNode is deprecated starting 5.0.x.

Environment

Product: TIBCO Adapter SDK Version: 5.3.0, 5.3.2, 5.4.0, 4.x, 5.0.x OS: All --------------------

Issue/Introduction

How can I create a node/tree to hold a datetime of an arbitrary value?What C/C++ data type would I pass to an append method?