20000412-11:01 GMT+1 Victor Szakats <info@szelvesz.hu>

This commit is contained in:
Viktor Szakats
2000-04-12 08:59:22 +00:00
parent cd5871699d
commit 6621e6ff4b
13 changed files with 191 additions and 92 deletions

View File

@@ -1,3 +1,31 @@
20000412-11:01 GMT+1 Victor Szakats <info@szelvesz.hu>
* include/hbdate.h
* include/hbapi.h
* source/rtl/datec.c
* source/rtl/dates.c
* source/rtl/dateshb.c
* source/tools/dates2.c
* source/vm/extend.c
* contrib/rdd_ads/ads1.c
* source/rdd/dbf1.c
* Day/Month/Year parameters reordered to Year/Month/Day to match
international conventions.
(hb_retd(), hb_dateDOW(), hb_dateEncode(), hb_dateDecode(),
hb_dateStrPut(), hb_dateStrGet())
; Next items by Jose Lalin.
* include/hbapirdd.h
+ added missing DBI_FULLPATH
! minor formating
! typos fixed, DBI_ definitions changed
+ tests/tstdbi.prg
* tests/Makefile
+ new tests for DbInfo()
+ new tests for dbRecordInfo() and dbFieldInfo()
20000412-10:06 GMT+1 Victor Szakats <info@szelvesz.hu>
* include/inkey.ch

View File

@@ -588,8 +588,8 @@ static ERRCODE adsPutValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem )
AdsGetDateFormat ( pucFormat, &pusLen );
AdsSetDateFormat ( (UCHAR*)"YYYYMMDD" );
szEndChar = * ( szText + pField->uiLen );
hb_dateDecode( hb_itemGetDL( pItem ), &lDay, &lMonth, &lYear );
hb_dateStrPut( ( char * ) szText, lDay, lMonth, lYear );
hb_dateDecode( hb_itemGetDL( pItem ), &lYear, &lMonth, &lDay );
hb_dateStrPut( ( char * ) szText, lYear, lMonth, lDay );
* ( szText + pField->uiLen ) = szEndChar;
AdsSetDate( pArea->hTable, szName, szText, 8 );
AdsSetDateFormat ( pucFormat );
@@ -773,9 +773,9 @@ static ERRCODE adsInfo( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem )
break;
}
case DBI_LASTUPDATE:
hb_itemPutDL( pItem, hb_dateEncode( pArea->lpExtendInfo->bDay,
hb_itemPutDL( pItem, hb_dateEncode( pArea->lpExtendInfo->bYear,
pArea->lpExtendInfo->bMonth,
pArea->lpExtendInfo->bYear ) );
pArea->lpExtendInfo->bDay ) );
break;
case DBI_GETRECSIZE:

View File

@@ -274,7 +274,7 @@ extern void hb_ret( void ); /* post a NIL return value */
extern void hb_retc( char * szText ); /* returns a string */
extern void hb_retclen( char * szText, ULONG ulLen ); /* returns a string with a specific length */
extern void hb_retds( char * szDate ); /* returns a date, must use yyyymmdd format */
extern void hb_retd( long lDay, long lMonth, long lYear ); /* returns a date */
extern void hb_retd( long lYear, long lMonth, long lDay ); /* returns a date */
extern void hb_retl( int iTrueFalse ); /* returns a logical integer */
extern void hb_retnd( double dNumber ); /* returns a double */
extern void hb_retni( int iNumber ); /* returns a integer number */

View File

@@ -100,6 +100,7 @@ extern void hb_rddShutDown( void );
#define DBI_GETRECSIZE 7 /* Numeric: Get record size of the file */
#define DBI_GETLOCKARRAY 8 /* Array: Get an array of locked records */
#define DBI_TABLEEXT 9 /* String: Get table file extension */
#define DBI_FULLPATH 10 /* String: Full path name of opened file */
#define DBI_ISFLOCK 20 /* Get file lock status */
@@ -111,7 +112,7 @@ extern void hb_rddShutDown( void );
#define DBI_DBFILTER 28 /* Filter expression */
#define DBI_FOUND 29 /* FOUND flag - alternate to found */
#define DBI_FCOUNT 30 /* Number of fields */
#define DBI_LOCKCOUNT 31 /* Get record size of the file */
#define DBI_LOCKCOUNT 31 /* Locked records */
#define DBI_VALIDBUFFER 32 /* Is the current buffer valid */
#define DBI_ALIAS 33 /* Alias name of workarea */
#define DBI_GETSCOPE 34 /* Locate codeblock */

View File

@@ -49,12 +49,12 @@ extern char * hb_dateDaysName [];
extern double hb_dateSeconds( void );
extern char * hb_dateCMonth( int iMonth );
extern char * hb_dateCDOW( int iDay );
extern long hb_dateDOW( long lDay, long lMonth, long lYear );
extern long hb_dateDOW( long lYear, long lMonth, long lDay );
extern char * hb_dateFormat( const char * szDate, char * szFormattedDate, const char * szDateFormat );
extern long hb_dateEncode( long lDay, long lMonth, long lYear );
extern void hb_dateDecode( long julian, long * plDay, long * plMonth, long * plYear );
extern void hb_dateStrPut( char * szDate, long lDay, long lMonth, long lYear );
extern void hb_dateStrGet( const char * szDate, long * plDay, long * plMonth, long * plYear );
extern long hb_dateEncode( long lYear, long lMonth, long lDay );
extern void hb_dateDecode( long julian, long * plYear, long * plMonth, long * plDay );
extern void hb_dateStrPut( char * szDate, long lYear, long lMonth, long lDay );
extern void hb_dateStrGet( const char * szDate, long * plYear, long * plMonth, long * plDay );
extern char * hb_dateDecStr( char * szDate, long lJulian );
extern long hb_dateEncStr( char * szDate );

View File

@@ -1240,9 +1240,9 @@ static ERRCODE dbfInfo( AREAP pArea, USHORT uiIndex, PHB_ITEM pItem )
break;
case DBI_LASTUPDATE:
hb_itemPutDL( pItem, hb_dateEncode( pArea->lpExtendInfo->bDay,
hb_itemPutDL( pItem, hb_dateEncode( pArea->lpExtendInfo->bYear,
pArea->lpExtendInfo->bMonth,
pArea->lpExtendInfo->bYear ) );
pArea->lpExtendInfo->bDay ) );
break;
case DBI_GETRECSIZE:
@@ -1560,8 +1560,8 @@ static ERRCODE dbfPutValue( AREAP pArea, USHORT uiIndex, PHB_ITEM pItem )
if( HB_IS_DATE( pItem ) )
{
szEndChar = * ( szText + pField->uiLen );
hb_dateDecode( hb_itemGetDL( pItem ), &lDay, &lMonth, &lYear );
hb_dateStrPut( ( char * ) szText, lDay, lMonth, lYear );
hb_dateDecode( hb_itemGetDL( pItem ), &lYear, &lMonth, &lDay );
hb_dateStrPut( ( char * ) szText, lYear, lMonth, lDay );
* ( szText + pField->uiLen ) = szEndChar;
bError = FALSE;
}

View File

@@ -58,9 +58,9 @@ HB_FUNC( CMONTH )
if( pDate )
{
long lDay, lMonth, lYear;
long lYear, lMonth, lDay;
hb_dateDecode( hb_itemGetDL( pDate ), &lDay, &lMonth, &lYear );
hb_dateDecode( hb_itemGetDL( pDate ), &lYear, &lMonth, &lDay );
hb_retc( hb_dateCMonth( lMonth ) );
}
else
@@ -85,10 +85,10 @@ HB_FUNC( CDOW )
if( lDate )
{
long lDay, lMonth, lYear;
long lYear, lMonth, lDay;
hb_dateDecode( lDate, &lDay, &lMonth, &lYear );
hb_retc( hb_dateCDOW( hb_dateDOW( lDay, lMonth, lYear ) ) );
hb_dateDecode( lDate, &lYear, &lMonth, &lDay );
hb_retc( hb_dateCDOW( hb_dateDOW( lYear, lMonth, lDay ) ) );
}
else
hb_retc( "" );

View File

@@ -58,9 +58,9 @@
#include "hbapi.h"
#include "hbdate.h"
long hb_dateEncode( long lDay, long lMonth, long lYear )
long hb_dateEncode( long lYear, long lMonth, long lDay )
{
HB_TRACE(HB_TR_DEBUG, ("hb_dateEncode(%ld, %ld, %ld)", lDay, lMonth, lYear));
HB_TRACE(HB_TR_DEBUG, ("hb_dateEncode(%ld, %ld, %ld)", lYear, lMonth, lDay));
/* Perform date validation */
if( lYear >= 1 && lYear <= 2999 &&
@@ -88,9 +88,9 @@ long hb_dateEncode( long lDay, long lMonth, long lYear )
return 0;
}
void hb_dateDecode( long lJulian, long * plDay, long * plMonth, long * plYear )
void hb_dateDecode( long lJulian, long * plYear, long * plMonth, long * plDay )
{
HB_TRACE(HB_TR_DEBUG, ("hb_dateDecode(%ld, %p, %p, %p)", lJulian, plDay, plMonth, plYear));
HB_TRACE(HB_TR_DEBUG, ("hb_dateDecode(%ld, %p, %p, %p)", lJulian, plYear, plMonth, plDay));
if( lJulian > 0 )
{
@@ -104,23 +104,23 @@ void hb_dateDecode( long lJulian, long * plDay, long * plMonth, long * plYear )
V = 80 * lJulian / 2447;
U = V / 11;
*plDay = lJulian - ( 2447 * V / 80 );
*plMonth = V + 2 - ( U * 12 );
*plYear = X + U + ( W - 49 ) * 100;
*plMonth = V + 2 - ( U * 12 );
*plDay = lJulian - ( 2447 * V / 80 );
}
else
{
*plDay =
*plYear =
*plMonth =
*plYear = 0;
*plDay = 0;
}
}
void hb_dateStrPut( char * szDate, long lDay, long lMonth, long lYear )
void hb_dateStrPut( char * szDate, long lYear, long lMonth, long lDay )
{
HB_TRACE(HB_TR_DEBUG, ("hb_dateStrPut(%p, %ld, %ld, %ld)", szDate, lDay, lMonth, lYear));
HB_TRACE(HB_TR_DEBUG, ("hb_dateStrPut(%p, %ld, %ld, %ld)", szDate, lYear, lMonth, lDay));
if( lDay && lMonth && lYear )
if( lYear && lMonth && lDay )
{
szDate[ 0 ] = ( lYear / 1000 ) + '0';
szDate[ 1 ] = ( ( lYear % 1000 ) / 100 ) + '0';
@@ -137,26 +137,26 @@ void hb_dateStrPut( char * szDate, long lDay, long lMonth, long lYear )
memset( szDate, ' ', 8 );
}
void hb_dateStrGet( const char * szDate, long * plDay, long * plMonth, long * plYear )
void hb_dateStrGet( const char * szDate, long * plYear, long * plMonth, long * plDay )
{
HB_TRACE(HB_TR_DEBUG, ("hb_dateStrGet(%s, %p, %p, %p)", szDate, plDay, plMonth, plYear));
HB_TRACE(HB_TR_DEBUG, ("hb_dateStrGet(%s, %p, %p, %p)", szDate, plYear, plMonth, plDay));
if( szDate && szDate[ 8 ] == '\0' )
{
/* Date string has correct length, so attempt to convert */
*plDay = ( ( szDate[ 6 ] - '0' ) * 10 ) + ( szDate[ 7 ] - '0' );
*plMonth = ( ( szDate[ 4 ] - '0' ) * 10 ) + ( szDate[ 5 ] - '0' );
*plYear = ( ( USHORT ) ( szDate[ 0 ] - '0' ) * 1000 ) +
( ( USHORT ) ( szDate[ 1 ] - '0' ) * 100 ) +
( ( USHORT ) ( szDate[ 2 ] - '0' ) * 10 ) +
( USHORT ) ( szDate[ 3 ] - '0' );
*plMonth = ( ( szDate[ 4 ] - '0' ) * 10 ) + ( szDate[ 5 ] - '0' );
*plDay = ( ( szDate[ 6 ] - '0' ) * 10 ) + ( szDate[ 7 ] - '0' );
}
else
{
/* Date string missing or bad length, so force an empty date */
*plDay =
*plYear =
*plMonth =
*plYear = 0;
*plDay = 0;
}
}
@@ -165,12 +165,12 @@ void hb_dateStrGet( const char * szDate, long * plDay, long * plMonth, long * pl
char * hb_dateDecStr( char * szDate, long lJulian )
{
long lDay, lMonth, lYear;
long lYear, lMonth, lDay;
HB_TRACE(HB_TR_DEBUG, ("hb_dateDecStr(%p, %ld)", szDate, lJulian));
hb_dateDecode( lJulian, &lDay, &lMonth, &lYear );
hb_dateStrPut( szDate, lDay, lMonth, lYear );
hb_dateDecode( lJulian, &lYear, &lMonth, &lDay );
hb_dateStrPut( szDate, lYear, lMonth, lDay );
szDate[ 8 ] = '\0';
return szDate;
@@ -178,13 +178,13 @@ char * hb_dateDecStr( char * szDate, long lJulian )
long hb_dateEncStr( char * szDate )
{
long lDay, lMonth, lYear;
long lYear, lMonth, lDay;
HB_TRACE(HB_TR_DEBUG, ("hb_dateEncStr(%s)", szDate));
hb_dateStrGet( szDate, &lDay, &lMonth, &lYear );
hb_dateStrGet( szDate, &lYear, &lMonth, &lDay );
return hb_dateEncode( lDay, lMonth, lYear );
return hb_dateEncode( lYear, lMonth, lDay );
}
/* NOTE: szFormattedDate must be an at least 11 chars wide buffer */
@@ -357,9 +357,9 @@ char * hb_dateFormat( const char * szDate, char * szFormattedDate, const char *
return szFormattedDate;
}
long hb_dateDOW( long lDay, long lMonth, long lYear )
long hb_dateDOW( long lYear, long lMonth, long lDay )
{
HB_TRACE(HB_TR_DEBUG, ("hb_dateDOW(%ld, %ld, %ld)", lDay, lMonth, lYear));
HB_TRACE(HB_TR_DEBUG, ("hb_dateDOW(%ld, %ld, %ld)", lYear, lMonth, lDay));
if( lMonth < 3 )
{

View File

@@ -231,9 +231,9 @@ HB_FUNC( YEAR )
if( pDate )
{
long lDay, lMonth, lYear;
long lYear, lMonth, lDay;
hb_dateDecode( hb_itemGetDL( pDate ), &lDay, &lMonth, &lYear );
hb_dateDecode( hb_itemGetDL( pDate ), &lYear, &lMonth, &lDay );
hb_retnllen( lYear, 5 );
}
@@ -255,9 +255,9 @@ HB_FUNC( MONTH )
if( pDate )
{
long lDay, lMonth, lYear;
long lYear, lMonth, lDay;
hb_dateDecode( hb_itemGetDL( pDate ), &lDay, &lMonth, &lYear );
hb_dateDecode( hb_itemGetDL( pDate ), &lYear, &lMonth, &lDay );
hb_retnllen( lMonth, 3 );
}
@@ -279,9 +279,9 @@ HB_FUNC( DAY )
if( pDate )
{
long lDay, lMonth, lYear;
long lYear, lMonth, lDay;
hb_dateDecode( hb_itemGetDL( pDate ), &lDay, &lMonth, &lYear );
hb_dateDecode( hb_itemGetDL( pDate ), &lYear, &lMonth, &lDay );
hb_retnllen( lDay, 3 );
}
@@ -355,11 +355,11 @@ HB_FUNC( DOW )
if( lDate )
{
long lDay, lMonth, lYear;
long lYear, lMonth, lDay;
hb_dateDecode( lDate, &lDay, &lMonth, &lYear );
hb_dateDecode( lDate, &lYear, &lMonth, &lDay );
hb_retnllen( hb_dateDOW( lDay, lMonth, lYear ), 3 );
hb_retnllen( hb_dateDOW( lYear, lMonth, lDay ), 3 );
}
else
hb_retnllen( 0, 3 );

View File

@@ -50,11 +50,11 @@ int hb_isleapyear( long lYear )
return (( lYear % 4 == 0 && lYear % 100 != 0 ) || lYear % 400 == 0 )?1:0;
}
long hb_daysinmonth( long lMonth, long lYear )
long hb_daysinmonth( long lYear, long lMonth )
{
int i;
HB_TRACE(HB_TR_DEBUG, ("hb_daysinmonth(%ld, %ld)", lMonth, lYear));
HB_TRACE(HB_TR_DEBUG, ("hb_daysinmonth(%ld, %ld)", lYear, lMonth));
i = hb_isleapyear( lYear );
if( lMonth > 0 && lMonth < 13 )
@@ -63,40 +63,40 @@ long hb_daysinmonth( long lMonth, long lYear )
return 0;
}
long hb_doy( long lDay, long lMonth, long lYear )
long hb_doy( long lYear, long lMonth, long lDay )
{
int i;
int iDoy = 0;
HB_TRACE(HB_TR_DEBUG, ("hb_doy(%ld, %ld, %ld)", lDay, lMonth, lYear));
HB_TRACE(HB_TR_DEBUG, ("hb_doy(%ld, %ld, %ld)", lYear, lMonth, lDay));
for( i = 1; i < lMonth; i++ )
iDoy += hb_daysinmonth( i, lYear );
iDoy += hb_daysinmonth( lYear, i );
iDoy += lDay;
return iDoy;
}
long hb_wom( long lDay, long lMonth, long lYear )
long hb_wom( long lYear, long lMonth, long lDay )
{
int iWom;
HB_TRACE(HB_TR_DEBUG, ("hb_wom(%ld, %ld, %ld)", lDay, lMonth, lYear));
HB_TRACE(HB_TR_DEBUG, ("hb_wom(%ld, %ld, %ld)", lYear, lMonth, lDay));
iWom = lDay + hb_dateDOW( 1, lMonth, lYear) - 1;
iWom = lDay + hb_dateDOW( lYear, lMonth, 1 ) - 1;
if( iWom > 0 )
return ( iWom - hb_dateDOW( lDay, lMonth, lYear ) ) / 7 + 1 ;
return ( iWom - hb_dateDOW( lYear, lMonth, lDay ) ) / 7 + 1 ;
else
return 0;
}
long hb_woy( long lDay, long lMonth, long lYear, BOOL bISO )
long hb_woy( long lYear, long lMonth, long lDay, BOOL bISO )
{
int iWeek, n;
HB_TRACE(HB_TR_DEBUG, ("hb_woy(%ld, %ld, %ld, %d)", lDay, lMonth, lYear, (int) bISO));
HB_TRACE(HB_TR_DEBUG, ("hb_woy(%ld, %ld, %ld, %d)", lYear, lMonth, lDay, (int) bISO));
lDay = hb_doy( lDay, lMonth, lYear );
lDay = hb_doy( lYear, lMonth, lDay );
n = ( ( ( 1 - (bISO ? 1 : 0) ) % 7 ) ) - 1;
lDay += (n>0)?1:0;
iWeek = lDay / 7;
@@ -147,9 +147,9 @@ HB_FUNC( ISLEAPYEAR )
if( ISDATE( 1 ) )
{
PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );
long lDay, lMonth, lYear;
long lYear, lMonth, lDay;
hb_dateDecode( hb_itemGetDL( pDate ), &lDay, &lMonth, &lYear );
hb_dateDecode( hb_itemGetDL( pDate ), &lYear, &lMonth, &lDay );
hb_retl( hb_isleapyear( lYear ) );
}
else
@@ -163,10 +163,10 @@ HB_FUNC( DAYSINMONTH )
if( ISDATE( 1 ) )
{
PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );
long lDay, lMonth, lYear;
long lYear, lMonth, lDay;
hb_dateDecode( hb_itemGetDL( pDate ), &lDay, &lMonth, &lYear );
hb_retni( hb_daysinmonth( lMonth, lYear ) );
hb_dateDecode( hb_itemGetDL( pDate ), &lYear, &lMonth, &lDay );
hb_retni( hb_daysinmonth( lYear, lMonth ) );
}
else
hb_retni( 0 );
@@ -177,11 +177,11 @@ HB_FUNC( EOM )
if( ISDATE( 1 ) )
{
PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );
long lDay, lMonth, lYear;
long lYear, lMonth, lDay;
char szDateFormat[ 9 ];
hb_dateDecode( hb_itemGetDL( pDate ), &lDay, &lMonth, &lYear );
lDay = hb_daysinmonth( lMonth, lYear );
hb_dateDecode( hb_itemGetDL( pDate ), &lYear, &lMonth, &lDay );
lDay = hb_daysinmonth( lYear, lMonth );
sprintf( szDateFormat, "%04i%02i%02i", (int) lYear, (int) lMonth, (int) lDay );
hb_retds( szDateFormat );
}
@@ -194,10 +194,10 @@ HB_FUNC( BOM )
if( ISDATE( 1 ) )
{
PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );
long lDay, lMonth, lYear;
long lYear, lMonth, lDay;
char szDateFormat[ 9 ];
hb_dateDecode( hb_itemGetDL( pDate ), &lDay, &lMonth, &lYear );
hb_dateDecode( hb_itemGetDL( pDate ), &lYear, &lMonth, &lDay );
sprintf( szDateFormat, "%04i%02i%02i", (int) lYear, (int) lMonth, 1 );
hb_retds( szDateFormat );
}
@@ -210,10 +210,10 @@ HB_FUNC( WOM )
if( ISDATE( 1 ) )
{
PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );
long lDay, lMonth, lYear;
long lYear, lMonth, lDay;
hb_dateDecode( hb_itemGetDL( pDate ), &lDay, &lMonth, &lYear );
hb_retni( hb_wom( lDay, lMonth, lYear ) );
hb_dateDecode( hb_itemGetDL( pDate ), &lYear, &lMonth, &lDay );
hb_retni( hb_wom( lYear, lMonth, lDay ) );
}
else
hb_retni( 0 );
@@ -224,10 +224,10 @@ HB_FUNC( DOY )
if( ISDATE( 1 ) )
{
PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );
long lDay, lMonth, lYear;
long lYear, lMonth, lDay;
hb_dateDecode( hb_itemGetDL( pDate ), &lDay, &lMonth, &lYear );
hb_retni( hb_doy( lDay, lMonth, lYear ) );
hb_dateDecode( hb_itemGetDL( pDate ), &lYear, &lMonth, &lDay );
hb_retni( hb_doy( lYear, lMonth, lDay ) );
}
else
hb_retni( 0 );
@@ -240,10 +240,10 @@ HB_FUNC( WOY )
if( ISDATE( 1 ) )
{
PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );
long lDay, lMonth, lYear;
long lYear, lMonth, lDay;
hb_dateDecode( hb_itemGetDL( pDate ), &lDay, &lMonth, &lYear );
hb_retni( hb_woy( lDay, lMonth, lYear, ISLOG( 2 ) ? hb_parl( 2 ) : TRUE ) );
hb_dateDecode( hb_itemGetDL( pDate ), &lYear, &lMonth, &lDay );
hb_retni( hb_woy( lYear, lMonth, lDay, ISLOG( 2 ) ? hb_parl( 2 ) : TRUE ) );
}
else
hb_retni( 0 );
@@ -254,10 +254,10 @@ HB_FUNC( EOY )
if( ISDATE( 1 ) )
{
PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );
long lDay, lMonth, lYear;
long lYear, lMonth, lDay;
char szDateFormat[ 9 ];
hb_dateDecode( hb_itemGetDL( pDate ), &lDay, &lMonth, &lYear );
hb_dateDecode( hb_itemGetDL( pDate ), &lYear, &lMonth, &lDay );
sprintf( szDateFormat, "%04i%02i%02i", (int) lYear, 12, 31 );
hb_retds( szDateFormat );
}
@@ -270,10 +270,10 @@ HB_FUNC( BOY )
if( ISDATE( 1 ) )
{
PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );
long lDay, lMonth, lYear;
long lYear, lMonth, lDay;
char szDateFormat[ 9 ];
hb_dateDecode( hb_itemGetDL( pDate ), &lDay, &lMonth, &lYear );
hb_dateDecode( hb_itemGetDL( pDate ), &lYear, &lMonth, &lDay );
sprintf( szDateFormat, "%04i%02i%02i", (int) lYear, 1, 1 );
hb_retds( szDateFormat );
}

View File

@@ -491,11 +491,11 @@ void hb_retds( char * szDate )
hb_itemPutDS( &hb_stack.Return, szDate );
}
void hb_retd( long lDay, long lMonth, long lYear )
void hb_retd( long lYear, long lMonth, long lDay )
{
HB_TRACE(HB_TR_DEBUG, ("hb_retd(%02i, %02i, %04i)", lDay, lMonth, lYear));
HB_TRACE(HB_TR_DEBUG, ("hb_retd(%04i, %02i, %02i)", lYear, lMonth, lDay));
hb_itemPutDL( &hb_stack.Return, hb_dateEncode( lDay, lMonth, lYear ) );
hb_itemPutDL( &hb_stack.Return, hb_dateEncode( lYear, lMonth, lDay ) );
}
void hb_retl( int iLogical )

View File

@@ -143,6 +143,7 @@ PRG_SOURCES=\
testwarn.prg \
tstalias.prg \
tstcolor.prg \
tstdbi.prg \
tstdspac.prg \
version.prg \
while.prg \

69
harbour/tests/tstdbi.prg Normal file
View File

@@ -0,0 +1,69 @@
/*
* $Id$
*/
#ifdef __HARBOUR__
#define CRLF hb_osnewline()
#else
#define CRLF chr(13)+chr(10)
#endif
funct main()
local i
local cStr := ""
USE "TEST" NEW
for i := 1 to 100
cStr += Str( i ) + " " + xToStr( DbInfo( i ) ) + CRLF
next
cStr += Str( 101 ) + " " + xToStr( DbInfo( 101 ) ) + CRLF
cStr += Str( 101 ) + " " + xToStr( DbInfo( 101, 1 ) ) + CRLF
cStr += Str( 101 ) + " " + xToStr( DbInfo( 101, 2 ) ) + CRLF
cStr += Str( 102 ) + " " + xToStr( DbInfo( 102 ) ) + CRLF
cStr += Str( 101 ) + " " + xToStr( DbInfo( 102, 1 ) ) + CRLF
cStr += Str( 101 ) + " " + xToStr( DbInfo( 102, 2 ) ) + CRLF
cStr += Str( 999 ) + " " + xToStr( DbInfo( 999 ) ) + CRLF
cStr += Str( 1000 ) + " " + xToStr( DbInfo( 1000 ) ) + CRLF
#ifdef __HARBOUR__
MemoWrit( "dbihb.txt", cStr )
#else
MemoWrit( "dbicl.txt", cStr )
#endif
? DbRecordInfo( 1 )
? DbRecordInfo( 2 )
? DbRecordInfo( 3 )
? DbRecordInfo( 4 )
? DbRecordInfo( 5 )
? DbFieldInfo( 1, 1 )
? DbFieldInfo( 2, 1 )
? DbFieldInfo( 3, 1 )
? DbFieldInfo( 4, 1 )
return nil
static function xToStr( xValue )
LOCAL cType := ValType( xValue )
LOCAL cRet := ""
do case
case cType == "N"
cRet := Str( xValue )
case cType == "D"
cRet := DToC( xValue )
case cType == "C" .or. cType == "M"
cRet := xValue
case cType == "L"
cRet := if( xValue, ".T.", ".F." )
case cType == "A"
cRet := "A" + AllTrim( Str( Len( xValue ) ) )
case cType == "U"
cRet := "NIL"
endcase
return cRet