added qse_getmtime() and qse_mtime_t to represent time in milliseconds

This commit is contained in:
hyung-hwan 2019-03-12 08:22:36 +00:00
parent c5c9c47e86
commit d41f8e75e0
2 changed files with 18 additions and 0 deletions

View File

@ -119,6 +119,8 @@ struct qse_btime_t
int gmtoff;
};
/* number of milliseconds since the Epoch (00:00:00 UTC, Jan 1, 1970) */
typedef qse_long_t qse_mtime_t;
#if defined(QSE_HAVE_INLINE)
static QSE_INLINE void qse_inittime(qse_ntime_t* x, qse_long_t s, qse_int32_t nsec)
@ -161,6 +163,13 @@ QSE_EXPORT int qse_gettime (
qse_ntime_t* nt
);
/**
* The qse_getmtime() function gets the current time in milliseconds.
*/
QSE_EXPORT int qse_getmtime (
qse_mtime_t* mt
);
/**
* The qse_settime() function sets the current time.
*/
@ -243,6 +252,7 @@ QSE_EXPORT int qse_wcs_to_ntime (
# define qse_str_to_ntime(text,ntime) qse_wcs_to_ntime(text,ntime)
#endif
#if defined(__cplusplus)
}
#endif

View File

@ -190,6 +190,14 @@ int qse_gettime (qse_ntime_t* t)
#endif
}
int qse_getmtime (qse_mtime_t* mt)
{
qse_ntime_t nt;
if (qse_gettime(&nt) <= -1) return -1;
*mt = QSE_SECNSEC_TO_MSEC(nt.sec, nt.nsec);
return 0;
}
int qse_settime (const qse_ntime_t* t)
{
#if defined(_WIN32)