Convert datetime between the application's and database's resolution.
mco_int8 mco_ticks2time(mco_int8 ticks, int scale);
| ticks | The number of time ticks since 1 Jan 1970 (Epoch) |
|
scale |
The resolution of time ticks: from 1 (second) to 1000000000 (nanoseconds) |
This function converts the argument
ticksto the corresponding value specified by the resolution argumentscale.
| mco_int8 | The value of ticks converted to the resolution scale |
Schema file snippet:
class Object
{
datetime dt;
...
};
Application snippet:
int main(int argc, char* argv[])
{
...
mco_trans_start(db, MCO_READ_WRITE, MCO_TRANS_FOREGROUND, &trans);
if ( MCO_S_OK != rc )
{
Object obj = T_new( trans, &obj );
rc = Object_dt_put( &obj, mco_ticks2time(mco_system_get_current_time(), 1000*1000));
...
}
}
Note that here the second argument of mco_ticks2time() is 1000*1000, because mco_system_get_current_time() returns time in microseconds.