added qse_ntoff_t

This commit is contained in:
hyung-hwan 2011-11-24 02:21:18 +00:00
parent 936353f809
commit 9550c71096
4 changed files with 21 additions and 9 deletions

View File

@ -63,19 +63,31 @@
#define QSE_SECNSEC_TO_MSEC(sec,nsec) \
(((qse_ntime_t)(sec) * QSE_MSECS_PER_SEC) + ((qse_ntime_t)(nsec) / QSE_NSECS_PER_MSEC))
/* number of milliseconds since the Epoch (00:00:00 UTC, Jan 1, 1970) */
/**
* The qse_ntime_t type defines a numeric time type expressed in the
* number of milliseconds since the Epoch (00:00:00 UTC, Jan 1, 1970).
*/
typedef qse_long_t qse_ntime_t;
/**
* The qse_ntoff_t type represents the amount of increment or decrement
* from a certain time point. It is defined to be type-compatible with
* #qse_ntime_t and expresses that you're dealing with time offset or amount,
* not an absolute time point.
*/
typedef qse_ntime_t qse_ntoff_t;
typedef struct qse_btime_t qse_btime_t;
struct qse_btime_t
{
int msec;
int msec; /* 0-999 */
int sec; /* 0-61 */
int min; /* 0-59 */
int hour; /* 0-23 */
int mday; /* 1-31 */
int mon; /* 0(jan)-11(dec) */
int year; /* the number of years since 1900 */
int year; /* the number of years since QSE_BTIME_YEAR_BASE */
int wday; /* 0(sun)-6(sat) */
int yday; /* 0(jan 1) to 365 */
int isdst;

View File

@ -109,7 +109,7 @@ int qse_gettime (qse_ntime_t* t)
rc = DosGetDateTime (&dt);
if (rc != NO_ERROR) return -1;
bt.year = dt.year - 1900;
bt.year = dt.year - QSE_BTIME_YEAR_BASE;
bt.mon = dt.month - 1;
bt.mday = dt.day;
bt.hour = dt.hours;
@ -130,7 +130,7 @@ int qse_gettime (qse_ntime_t* t)
_dos_gettime (&dt);
_dos_getdate (&dd);
bt.year = dd.year - 1900;
bt.year = dd.year - QSE_BTIME_YEAR_BASE;
bt.mon = dd.month - 1;
bt.mday = dd.day;
bt.hour = dt.hour;
@ -175,7 +175,7 @@ int qse_settime (qse_ntime_t t)
if (qse_localtime (t, &bt) <= -1) return -1;
QSE_MEMSET (&dt, 0, QSE_SIZEOF(dt));
dt.year = bt.year + 1900;
dt.year = bt.year + QSE_BTIME_YEAR_BASE;
dt.month = bt.mon + 1;
dt.day = bt.mday;
dt.hours = bt.hour;
@ -194,7 +194,7 @@ int qse_settime (qse_ntime_t t)
if (qse_localtime (t, &bt) <= -1) return -1;
dd.year = bt.year + 1900;
dd.year = bt.year + QSE_BTIME_YEAR_BASE;
dd.month = bt.mon + 1;
dd.day = bt.mday;
dt.hour = bt.hour;

View File

@ -34,7 +34,7 @@ static void list (qse_fs_t* fs, const qse_char_t* name)
qse_printf (QSE_T("%s %16lu %04d-%02d-%02d %02d:%02d %s\n"),
((ent->type == QSE_FS_ENT_SUBDIR)? QSE_T("<D>"): QSE_T(" ")),
(unsigned long)ent->size,
bt.year + 1900, bt.mon+1, bt.mday, bt.hour, bt.min,
bt.year + QSE_BTIME_YEAR_BASE, bt.mon+1, bt.mday, bt.hour, bt.min,
ent->name.base
);
}

View File

@ -34,7 +34,7 @@ static void list (qse_dir_t* dir, const qse_char_t* name)
qse_printf (QSE_T("%s %16lu %04d-%02d-%02d %02d:%02d %s\n"),
((ent->type == QSE_DIR_ENT_SUBDIR)? QSE_T("<D>"): QSE_T(" ")),
(unsigned long)ent->size,
bt.year + 1900, bt.mon+1, bt.mday, bt.hour, bt.min,
bt.year + QSE_BTIME_YEAR_BASE, bt.mon+1, bt.mday, bt.hour, bt.min,
ent->name.base
);
}