mco_time2ticks

Convert datetime between the application's and database's resolution.

Prototype

 
    mco_int8 mco_time2ticks(mco_int8 time, int scale);
 

Arguments

ticks The number of time ticks since 1 Jan 1970 (Epoch)

scale

The resolution of time ticks: from 1 (second) to 1000000000 (nanoseconds)

Description

This function converts the argument time to the corresponding value specified by the resolution argument scale.

Return Value

mco_int8 The value of ticks converted to the resolution scale

Example

 
    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 )
        {
            mco_datetime dt;
            ...
            T_dt_get(&obj, &dt);
            printf("dt (in msecs) = %llu, dt (in usecs) = %llu\n", t, d, 
                mco_time2ticks(dt, 1000), mco_time2ticks(dt, 1000*1000));
            ...
        }
    }
     
 

Related Topics Link IconRelated Topics

Note that if we want to get datetime in milliseconds, we call mco_time2ticks() with 1000 as the second parameter; for microseconds the second parameter must be 1000*1000.

Files

Header file:
mcotime.h
Source file:
mcodb.c
Library:
libmcolib.a
Header file:
mcotime.h
Source file:
corestub.c
Library:
libmcorsqlstub.a