mardi 19 décembre 2017

C++ custom time date struct to utc epoch

I use a library that uses the following struct to define a start timestamp as follows.

    struct SYSTEMTIME {
    /** year */
    WORD year;

    /** month */
    WORD month;

    /** day of week */
    WORD dayOfWeek;

    /** day */
    WORD day;

    /** hour */
    WORD hour;

    /** minute */
    WORD minute;

    /** second */
    WORD second;

    /** milliseconds */
    WORD milliseconds;
};

For every log entry after this time is specified in nanoseconds difference from this first timestamp.

Lets say its UTC 2017-12-19 14:44:00 And the first following log entries are 397000ns after this.

How do I create a chronos, time_t or unix time from epoch from the first SYSTEMTIME struct and then add the nanoseconds to it.

Printout should be for this first entry 2017-12-19 14:44:00.000397

Best regards

Aucun commentaire:

Enregistrer un commentaire