From d41f8e75e0d9b41085bfda5515b8f92ee079ab87 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Tue, 12 Mar 2019 08:22:36 +0000 Subject: [PATCH] added qse_getmtime() and qse_mtime_t to represent time in milliseconds --- qse/include/qse/cmn/time.h | 10 ++++++++++ qse/lib/cmn/time.c | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/qse/include/qse/cmn/time.h b/qse/include/qse/cmn/time.h index 79c320f4..1667676c 100644 --- a/qse/include/qse/cmn/time.h +++ b/qse/include/qse/cmn/time.h @@ -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 diff --git a/qse/lib/cmn/time.c b/qse/lib/cmn/time.c index cd964c91..7013f5e3 100644 --- a/qse/lib/cmn/time.c +++ b/qse/lib/cmn/time.c @@ -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)