diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 27743db423..9f4133e0e1 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,24 @@ +19990607-19:45 EDT David G. Holm + * include/extend.h + - Moved "#include " to include/types.h + * include/types.h + - Moved "#include " from include/extend.h in order to + avoid having to require that extend.h be included before set.h + * source/rtl/dates.c + - HARBOUR SECONDS() and support module hb_seconds() courtesy of + Jose Lalin . I removed the use of clock() + from hb_time(), because clock() returns the number of clock + ticks since the program started, which has no relationship to + when the seconds of the real time clock roll over. This means + that SECONDS() will always return whole seconds instead of + seconds and hundredths. I also provided an alternate hb_seconds + implementation for DOS platforms using gettime() instead of + time() and localtime(), because gettime() includes 1/100ths. + * source/rtl/files.c + - Don't "#include " if compiling with DJGPP. + + tests/working/seconds.prg + - New test program for SECONDS(). + 19990607-20:30 CET Eddie Runia * makefile.b32 change little bug (hb.c) diff --git a/harbour/include/extend.h b/harbour/include/extend.h index a3d30c700e..3addefe4ab 100644 --- a/harbour/include/extend.h +++ b/harbour/include/extend.h @@ -5,16 +5,15 @@ #ifndef _EXTEND_H #define _EXTEND_H -#define FILE _FILE /* to avoid conflicts with Harbour File() */ +//#define FILE _FILE /* to avoid conflicts with Harbour File() */ -#include #include #include #include #include #include -#undef FILE +//#undef FILE typedef struct /* symbol support structure */ { diff --git a/harbour/include/types.h b/harbour/include/types.h index 74ddd18127..82e968da03 100644 --- a/harbour/include/types.h +++ b/harbour/include/types.h @@ -5,6 +5,8 @@ #ifndef _TYPES_H #define _TYPES_H +#include + #ifdef __IBMCPP__ #define INCL_TYPES #include diff --git a/harbour/source/rtl/dates.c b/harbour/source/rtl/dates.c index f9071d1017..a20397c7eb 100644 --- a/harbour/source/rtl/dates.c +++ b/harbour/source/rtl/dates.c @@ -6,6 +6,9 @@ #include #include #include +#if defined(__TURBOC__) || defined(__BORLANDC__) || defined(__DJGPP__) + #include +#endif #ifndef _STRICT_CLIPPER_COMPATIBILITY #define _OPTIMIZE_DTOS @@ -22,6 +25,23 @@ extern STACK stack; extern char *hb_monthsname[]; extern char *hb_daysname[]; +double hb_seconds( void ) +{ +#if defined(__TURBOC__) || defined(__BORLANDC__) || defined(__DJGPP__) + struct time t; + gettime( &t ); + return( ( ( t.ti_hour * 3600 ) + ( t.ti_min * 60 ) + t.ti_sec ) + t.ti_hund / 100.0 ); +#else + time_t t; + struct tm *oTime; + + time(&t); + oTime = localtime(&t); + + return( ( oTime->tm_hour * 3600 ) + ( oTime->tm_min * 60 ) + oTime->tm_sec ); +#endif +} + char *hb_cmonth( int month ) { if( month >= 1 && month <= 12 ) @@ -566,3 +586,17 @@ HARBOUR CDOW( void ) _errRelease(pError); } } + +HARBOUR SECONDS( void ) +{ + if( _pcount() == 0 ) + _retnd( hb_seconds() ); + else + { + /* QUESTION: Clipper catches this at compile time! */ + PHB_ITEM pError = _errNew(); + _errPutDescription(pError, "Incorrect number of arguments: SECONDS"); + _errLaunch(pError); + _errRelease(pError); + } +} diff --git a/harbour/source/rtl/files.c b/harbour/source/rtl/files.c index 7d2885fffd..5ae84e284b 100644 --- a/harbour/source/rtl/files.c +++ b/harbour/source/rtl/files.c @@ -5,7 +5,7 @@ #include #include -#if defined(__GNUC__) +#if defined(__GNUC__) && !defined(__DJGPP__) #include #endif diff --git a/harbour/tests/working/seconds.prg b/harbour/tests/working/seconds.prg new file mode 100644 index 0000000000..796ebb906a --- /dev/null +++ b/harbour/tests/working/seconds.prg @@ -0,0 +1,12 @@ +/* Test SECONDS() */ + +function Main() +local n + + QOUT(SECONDS()) + FOR n := 1 TO 10 + __ACCEPT("Pause: ") + QOUT(SECONDS()) + NEXT + +return NIL