Changed time_t type to time32_t
This commit is contained in:
@@ -155,7 +155,7 @@ inline int is_dir(const std::string& path) { return is_dir(path.c_str()); }
|
||||
inline bool fexist(const char* filename) { return *filename ? ((access(filename, R_OK) == 0) and not is_dir(filename)) : false; }
|
||||
inline bool fexist(const std::string& filename) { return fexist(filename.c_str()); }
|
||||
|
||||
dword gfixstattime(time_t st_time);
|
||||
dword gfixstattime(time32_t st_time);
|
||||
|
||||
dword GetFiletime(const char* file);
|
||||
inline dword GetFiletime(const std::string& file) { return GetFiletime(file.c_str()); }
|
||||
|
@@ -96,7 +96,7 @@ long GetFilesize(const char* file) {
|
||||
// ------------------------------------------------------------------
|
||||
// Convert time returned with stat to FFTime
|
||||
|
||||
dword gfixstattime(time_t st_time) {
|
||||
dword gfixstattime(time32_t st_time) {
|
||||
|
||||
#if (defined(__MINGW32__) && !defined(__MSVCRT__)) || defined(__CYGWIN__)
|
||||
struct tm &f = *ggmtime(&st_time);
|
||||
|
@@ -36,7 +36,7 @@
|
||||
|
||||
struct tm* glog::time_now;
|
||||
int glog::count = 0;
|
||||
time_t glog::secs_now;
|
||||
time32_t glog::secs_now;
|
||||
char glog::timebuf[20];
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ void glog::printf(const char* format, ...) {
|
||||
char buf[256];
|
||||
char logbuf[256];
|
||||
|
||||
secs_now = time(NULL);
|
||||
secs_now = gtime(NULL);
|
||||
time_now = glocaltime(&secs_now);
|
||||
|
||||
lineswritten++;
|
||||
|
@@ -61,7 +61,7 @@ private:
|
||||
|
||||
static int count;
|
||||
static struct tm* time_now;
|
||||
static time_t secs_now;
|
||||
static time32_t secs_now;
|
||||
static char timebuf[20];
|
||||
|
||||
protected:
|
||||
|
@@ -123,40 +123,54 @@ extern const char* gmonths[];
|
||||
// ------------------------------------------------------------------
|
||||
// Prototypes
|
||||
|
||||
inline struct tm *ggmtime(const time_t *timep)
|
||||
inline struct tm *ggmtime(const time32_t *timep)
|
||||
{
|
||||
const time_t temp(*timep);
|
||||
#if defined(__WIN32__)
|
||||
const time_t zero(0);
|
||||
struct tm *time = gmtime(timep);
|
||||
struct tm *time = gmtime(&temp);
|
||||
return time ? time : gmtime(&zero);
|
||||
#else
|
||||
return gmtime(&timep);
|
||||
return gmtime(&temp);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline struct tm* glocaltime(const time_t *timep)
|
||||
inline struct tm *glocaltime(const time32_t *timep)
|
||||
{
|
||||
const time_t temp(*timep);
|
||||
#if defined(__WIN32__)
|
||||
const time_t zero(0);
|
||||
struct tm *time = localtime(timep);
|
||||
struct tm *time = localtime(&temp);
|
||||
return time ? time : localtime(&zero);
|
||||
#else
|
||||
return localtime(timep);
|
||||
return localtime(&temp);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline struct tm* ggmtime(const time32_t *timep)
|
||||
inline char *gctime(const time32_t *timep)
|
||||
{
|
||||
const time_t temp(*timep);
|
||||
return ggmtime(&temp);
|
||||
#if defined(__WIN32__)
|
||||
const time_t zero(0);
|
||||
char *time = ctime(&temp);
|
||||
return time ? time : ctime(&zero);
|
||||
#else
|
||||
return ctime(&temp);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline struct tm* glocaltime(const time32_t *timep)
|
||||
inline time32_t gtime(time32_t *timep)
|
||||
{
|
||||
const time_t temp(*timep);
|
||||
return glocaltime(&temp);
|
||||
time32_t temp = (time32_t)time(NULL);
|
||||
return timep ? *timep = temp : temp;
|
||||
}
|
||||
|
||||
inline time32_t gmktime(struct tm *timep)
|
||||
{
|
||||
return (time32_t)mktime(timep);
|
||||
}
|
||||
|
||||
|
||||
#if defined(__OS2__)
|
||||
inline void usleep(long duration) { DosSleep(duration); }
|
||||
#elif defined(__MINGW32__) || defined(_MSC_VER)
|
||||
@@ -178,13 +192,13 @@ int tzoffset();
|
||||
|
||||
char* strftimei(char* s, size_t maxsize, const char* fmt, const struct tm* t); // __attribute__ ((format (strftime, 3, 0)));
|
||||
|
||||
FTime TimeToFTime(time_t __time) __attribute__ ((const));
|
||||
time_t FTimeToTime(FTime* __ftime, struct tm* __tm=NULL);
|
||||
FTime TimeToFTime(time32_t __time) __attribute__ ((const));
|
||||
time32_t FTimeToTime(FTime* __ftime, struct tm* __tm=NULL);
|
||||
|
||||
time_t FidoTimeToUnix(char* __fidotime);
|
||||
time32_t FidoTimeToUnix(char* __fidotime);
|
||||
|
||||
char* FTimeToStr(char* buf, FTime &t);
|
||||
char* TimeToStr(char* buf, time_t t);
|
||||
char* TimeToStr(char* buf, time32_t t);
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
@@ -60,10 +60,10 @@ const char* gmonths[] = {
|
||||
|
||||
int tzoffset() {
|
||||
|
||||
time_t t1 = time(NULL);
|
||||
time32_t t1 = gtime(NULL);
|
||||
struct tm *tp = ggmtime(&t1);
|
||||
tp->tm_isdst=-1;
|
||||
time_t t2 = mktime(tp);
|
||||
tp->tm_isdst = -1;
|
||||
time32_t t2 = gmktime(tp);
|
||||
int dt = (int)(t1 - t2);
|
||||
return (dt / 3600) * 100 + (dt % 3600) / 60;
|
||||
}
|
||||
@@ -329,7 +329,7 @@ int str2mon(const char* ptr) {
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
time_t FTimeToTime(FTime* __ftime, struct tm* __tm) {
|
||||
time32_t FTimeToTime(FTime* __ftime, struct tm* __tm) {
|
||||
|
||||
struct tm _tm;
|
||||
ulong _time = 0;
|
||||
@@ -350,10 +350,10 @@ time_t FTimeToTime(FTime* __ftime, struct tm* __tm) {
|
||||
__tm->tm_sec = __ftime->ft_tsec * 2;
|
||||
__tm->tm_isdst = -1;
|
||||
|
||||
time_t a = mktime(__tm);
|
||||
time32_t a = gmktime(__tm);
|
||||
struct tm *tp = ggmtime(&a);
|
||||
tp->tm_isdst = -1;
|
||||
time_t b = mktime(tp);
|
||||
tp->tm_isdst = -1;
|
||||
time32_t b = gmktime(tp);
|
||||
_time = a + a - b;
|
||||
|
||||
if(_time == (ulong)0xFFFFFFFFL)
|
||||
@@ -368,7 +368,7 @@ time_t FTimeToTime(FTime* __ftime, struct tm* __tm) {
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
FTime TimeToFTime(time_t __time) {
|
||||
FTime TimeToFTime(time32_t __time) {
|
||||
|
||||
FTime _ft;
|
||||
memset(&_ft, 0, sizeof(FTime));
|
||||
@@ -390,7 +390,7 @@ FTime TimeToFTime(time_t __time) {
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
time_t FidoTimeToUnix(char* ptr) {
|
||||
time32_t FidoTimeToUnix(char* ptr) {
|
||||
|
||||
bool date_ok = false;
|
||||
int year=0, month=0, day=0;
|
||||
@@ -441,10 +441,10 @@ time_t FidoTimeToUnix(char* ptr) {
|
||||
t.tm_min = minute;
|
||||
t.tm_sec = second;
|
||||
t.tm_isdst = -1;
|
||||
time_t a = mktime(&t);
|
||||
time32_t a = gmktime(&t);
|
||||
struct tm *tp = ggmtime(&a);
|
||||
tp->tm_isdst = -1;
|
||||
time_t b = mktime(tp);
|
||||
tp->tm_isdst = -1;
|
||||
time32_t b = gmktime(tp);
|
||||
return a + a - b;
|
||||
}
|
||||
return (ulong)-1;
|
||||
@@ -453,7 +453,7 @@ time_t FidoTimeToUnix(char* ptr) {
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
char* TimeToStr(char* buf, time_t t) {
|
||||
char* TimeToStr(char* buf, time32_t t) {
|
||||
|
||||
return strftimei(buf, 20, "%Y-%m-%d %H:%M:%S", ggmtime(&t));
|
||||
}
|
||||
|
Reference in New Issue
Block a user