2009-01-09 17:59 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/contrib/hbct/ftoc.c
* harbour/contrib/hbct/misc1.c
* changed XTOC(), FTOC() and CTOF() to always store/retirve numbers as
double value in little endian order to reduce platform differences
; TOFIX intorduce new macro which can be used instead sizeof( double )
for platforms where double size is different then 8 and macro
HB_FORCE_IEEE754_DOUBLE is set
* harbour/contrib/hbct/dattime2.c
* changed date functions to use default date like in CT3
This commit is contained in:
@@ -8,6 +8,18 @@
|
||||
2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org)
|
||||
*/
|
||||
|
||||
2009-01-09 17:59 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/contrib/hbct/ftoc.c
|
||||
* harbour/contrib/hbct/misc1.c
|
||||
* changed XTOC(), FTOC() and CTOF() to always store/retirve numbers as
|
||||
double value in little endian order to reduce platform differences
|
||||
; TOFIX intorduce new macro which can be used instead sizeof( double )
|
||||
for platforms where double size is different then 8 and macro
|
||||
HB_FORCE_IEEE754_DOUBLE is set
|
||||
|
||||
* harbour/contrib/hbct/dattime2.c
|
||||
* changed date functions to use default date like in CT3
|
||||
|
||||
2009-01-09 13:35 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/source/vm/classes.c
|
||||
* updated __objHasMsgAssigned()
|
||||
|
||||
@@ -72,7 +72,8 @@
|
||||
|
||||
static BOOL ct_isleap( int iYear )
|
||||
{
|
||||
return ( ( ( iYear & 3 ) == 0 && iYear % 100 != 0 ) || iYear % 400 == 0 );
|
||||
return iYear != 0 && ( ( ( iYear & 3 ) == 0 && iYear % 100 != 0 ) ||
|
||||
iYear % 400 == 0 );
|
||||
}
|
||||
|
||||
static int ct_daysinmonth( int iMonth, BOOL bLeap )
|
||||
@@ -294,9 +295,7 @@ HB_FUNC( DMY )
|
||||
|
||||
if( ISDATE( 1 ) )
|
||||
{
|
||||
PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );
|
||||
|
||||
hb_dateDecode( hb_itemGetDL( pDate ), &iYear, &iMonth, &iDay );
|
||||
hb_dateDecode( hb_pardl( 1 ), &iYear, &iMonth, &iDay );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -395,9 +394,7 @@ HB_FUNC( MDY )
|
||||
|
||||
if( ISDATE( 1 ) )
|
||||
{
|
||||
PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );
|
||||
|
||||
hb_dateDecode( hb_itemGetDL( pDate ), &iYear, &iMonth, &iDay );
|
||||
hb_dateDecode( hb_pardl( 1 ), &iYear, &iMonth, &iDay );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -477,22 +474,18 @@ HB_FUNC( ADDMONTH )
|
||||
{
|
||||
int iYear, iMonth, iDay, iNum, iDays;
|
||||
|
||||
if( ISDATE( 1 ) )
|
||||
{
|
||||
PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );
|
||||
|
||||
hb_dateDecode( hb_itemGetDL( pDate ), &iYear, &iMonth, &iDay );
|
||||
iNum = hb_parni( 2 );
|
||||
}
|
||||
else if( ISNUM( 1 ) )
|
||||
if( ISNUM( 1 ) )
|
||||
{
|
||||
iNum = hb_parni( 1 );
|
||||
hb_dateToday( &iYear, &iMonth, &iDay );
|
||||
}
|
||||
else
|
||||
{
|
||||
hb_retdl( 0 );
|
||||
return;
|
||||
if( ISDATE( 1 ) )
|
||||
hb_dateDecode( hb_pardl( 1 ), &iYear, &iMonth, &iDay );
|
||||
else
|
||||
hb_dateToday( &iYear, &iMonth, &iDay );
|
||||
iNum = hb_parni( 2 );
|
||||
}
|
||||
|
||||
iMonth += iNum;
|
||||
@@ -548,11 +541,10 @@ HB_FUNC( ADDMONTH )
|
||||
HB_FUNC( DOY )
|
||||
{
|
||||
LONG lDate;
|
||||
PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );
|
||||
|
||||
if( pDate )
|
||||
if( ISDATE( 1 ) )
|
||||
{
|
||||
lDate = hb_itemGetDL( pDate );
|
||||
lDate = hb_pardl( 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -595,11 +587,10 @@ HB_FUNC( DOY )
|
||||
HB_FUNC( ISLEAP )
|
||||
{
|
||||
int iYear, iMonth, iDay;
|
||||
PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );
|
||||
|
||||
if( pDate && hb_itemGetDL( pDate ) )
|
||||
if( ISDATE( 1 ) )
|
||||
{
|
||||
hb_dateDecode( hb_itemGetDL( pDate ), &iYear, &iMonth, &iDay );
|
||||
hb_dateDecode( hb_pardl( 1 ), &iYear, &iMonth, &iDay );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -716,19 +707,10 @@ HB_FUNC( DAYSINMONTH )
|
||||
HB_FUNC( QUARTER )
|
||||
{
|
||||
int iYear, iMonth, iDay;
|
||||
PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );
|
||||
|
||||
if( pDate )
|
||||
if( ISDATE( 1 ) )
|
||||
{
|
||||
if( hb_itemGetDL( pDate ) )
|
||||
{
|
||||
hb_dateDecode( hb_itemGetDL( pDate ), &iYear, &iMonth, &iDay );
|
||||
}
|
||||
else
|
||||
{
|
||||
hb_retni( 0 );
|
||||
return;
|
||||
}
|
||||
hb_dateDecode( hb_pardl( 1 ), &iYear, &iMonth, &iDay );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -774,14 +756,15 @@ HB_FUNC( LASTDAYOM )
|
||||
BOOL bLeap = 0;
|
||||
int iYear, iMonth, iDay;
|
||||
|
||||
if( ISDATE( 1 ) )
|
||||
if( ISNUM( 1 ) )
|
||||
{
|
||||
PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );
|
||||
LONG lDate = hb_itemGetDL( pDate );
|
||||
|
||||
if( lDate )
|
||||
iMonth = hb_parni( 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( ISDATE( 1 ) )
|
||||
{
|
||||
hb_dateDecode( lDate, &iYear, &iMonth, &iDay );
|
||||
hb_dateDecode( hb_pardl( 1 ), &iYear, &iMonth, &iDay );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -789,14 +772,6 @@ HB_FUNC( LASTDAYOM )
|
||||
}
|
||||
bLeap = ct_isleap( iYear );
|
||||
}
|
||||
else if( ISNUM( 1 ) )
|
||||
{
|
||||
iMonth = hb_parni( 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
iMonth = 0;
|
||||
}
|
||||
|
||||
hb_retni( ( iMonth && ( iMonth <= 12 ) ? ct_daysinmonth( iMonth, bLeap ) : 0 ) );
|
||||
|
||||
@@ -908,22 +883,12 @@ HB_FUNC( NTOCMONTH )
|
||||
HB_FUNC( WEEK )
|
||||
{
|
||||
int iYear, iMonth, iDay, iWeek;
|
||||
PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );
|
||||
LONG lDate = 0;
|
||||
LONG lDate;
|
||||
BOOL bSWN = ( ISLOG( 2 ) ? hb_parl( 2 ) : FALSE );
|
||||
|
||||
if( ISDATE( 1 ) )
|
||||
{
|
||||
lDate = hb_itemGetDL( pDate );
|
||||
if( !lDate )
|
||||
{
|
||||
hb_retni( 0 );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if( lDate )
|
||||
{
|
||||
lDate = hb_pardl( 1 );
|
||||
hb_dateDecode( lDate, &iYear, &iMonth, &iDay );
|
||||
}
|
||||
else
|
||||
@@ -932,7 +897,11 @@ HB_FUNC( WEEK )
|
||||
lDate = hb_dateEncode( iYear, iMonth, iDay );
|
||||
}
|
||||
|
||||
if( bSWN )
|
||||
if( !lDate )
|
||||
{
|
||||
iWeek = 0;
|
||||
}
|
||||
else if( bSWN )
|
||||
{
|
||||
int iDays = ct_daystomonth( iMonth, ct_isleap( iYear ) ) + iDay;
|
||||
int iPart = ( iDays % 7 );
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
* $ONELINER$
|
||||
* $SYNTAX$
|
||||
* FTOC( <nFloatingPointNumber> ) --> cFloatingPointNumber
|
||||
*
|
||||
*
|
||||
* $ARGUMENTS$
|
||||
* <nFloatingPointNumber> Designate any Harbour number.
|
||||
*
|
||||
@@ -74,7 +74,7 @@
|
||||
* Harbour internal numbers in Floating Point are stored in data type
|
||||
* DOUBLE. FTOC() returns these bits as an string. In this way,
|
||||
* numbers con be saved more compactly.
|
||||
*
|
||||
*
|
||||
* TODO: add documentation
|
||||
* $EXAMPLES$
|
||||
* $TESTS$
|
||||
@@ -92,15 +92,11 @@
|
||||
|
||||
HB_FUNC( FTOC )
|
||||
{
|
||||
union
|
||||
{
|
||||
double value;
|
||||
char string[sizeof( double )];
|
||||
} xConvert;
|
||||
char buf[ sizeof( double ) ];
|
||||
double d = hb_parnd( 1 );
|
||||
|
||||
xConvert.value = hb_parnd( 1 );
|
||||
|
||||
hb_retclen( xConvert.string, sizeof( double ) );
|
||||
HB_PUT_LE_DOUBLE( buf, d );
|
||||
hb_retclen( buf, sizeof( buf ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +108,7 @@ HB_FUNC( FTOC )
|
||||
* $ONELINER$
|
||||
* $SYNTAX$
|
||||
* CTOF( <cFloatingPointNumber> ) --> nFloatingPointNumber
|
||||
*
|
||||
*
|
||||
* $ARGUMENTS$
|
||||
* <cFloatingPointNumber> Designate a string that contains a Harbour
|
||||
* number in flotaing point format.
|
||||
@@ -126,7 +122,7 @@ HB_FUNC( FTOC )
|
||||
* $DESCRIPTION$
|
||||
* Character strings created with FTOC() or XTOC() are convert into
|
||||
* Harbour floating point number
|
||||
*
|
||||
*
|
||||
* TODO: add documentation
|
||||
* $EXAMPLES$
|
||||
* $TESTS$
|
||||
@@ -144,16 +140,11 @@ HB_FUNC( FTOC )
|
||||
|
||||
HB_FUNC( CTOF )
|
||||
{
|
||||
union
|
||||
{
|
||||
double value;
|
||||
char string[sizeof( double )];
|
||||
} xConvert;
|
||||
|
||||
if( hb_parclen( 1 ) >= sizeof( double ) )
|
||||
{
|
||||
memcpy( xConvert.string, hb_parc( 1 ), sizeof( double ) );
|
||||
hb_retnd( xConvert.value );
|
||||
const char * buf = hb_parc( 1 );
|
||||
|
||||
hb_retnd( HB_GET_LE_DOUBLE( buf ) );
|
||||
}
|
||||
else
|
||||
hb_retnd( 0.0 );
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
* $ONELINER$
|
||||
* $SYNTAX$
|
||||
* XTOC( <expValue> ) --> cValue
|
||||
*
|
||||
*
|
||||
* $ARGUMENTS$
|
||||
* <expValue> Designate an expression of some of the following data
|
||||
* type: NUMBER, CHARACTER, DATE, LOGICAL.
|
||||
@@ -69,13 +69,10 @@
|
||||
* $RETURNS$
|
||||
* XTOC() return a string with the representation of data type of
|
||||
* expValue.
|
||||
* ATTENTION: different implementations or platforms of Harbour, they
|
||||
* could produce different format in the string returned by XTOC() for
|
||||
* data type NUMBER.
|
||||
*
|
||||
* $DESCRIPTION$
|
||||
* Each data type always returns a string with a particular fixed length:
|
||||
*
|
||||
*
|
||||
* -----------------------------------------------------------
|
||||
* Data Type Result Length Similar function
|
||||
* -----------------------------------------------------------
|
||||
@@ -84,7 +81,7 @@
|
||||
* Date 8 DTOS()
|
||||
* String Unchanged
|
||||
* -----------------------------------------------------------
|
||||
*
|
||||
*
|
||||
* TODO: add documentation
|
||||
* $EXAMPLES$
|
||||
* $TESTS$
|
||||
@@ -102,23 +99,20 @@
|
||||
|
||||
HB_FUNC( XTOC )
|
||||
{
|
||||
union
|
||||
{
|
||||
double value;
|
||||
char string[sizeof( double )];
|
||||
} xConvert;
|
||||
|
||||
if( ISCHAR( 1 ) )
|
||||
hb_retc( hb_parc( 1 ) );
|
||||
else if( ISDATE( 1 ) )
|
||||
hb_retc( hb_pards( 1 ) );
|
||||
else if( ISNUM( 1 ) )
|
||||
{
|
||||
xConvert.value = hb_parnd( 1 );
|
||||
hb_retclen( xConvert.string, sizeof( double ) );
|
||||
char buf[ sizeof( double ) ];
|
||||
double d = hb_parnd( 1 );
|
||||
|
||||
HB_PUT_LE_DOUBLE( buf, d );
|
||||
hb_retclen( buf, sizeof( buf ) );
|
||||
}
|
||||
else if( ISLOG( 1 ) )
|
||||
hb_retclen( hb_parl( 1 ) ? "T" : "F", 1 );
|
||||
else
|
||||
hb_retc( NULL );
|
||||
hb_itemReturn( hb_param( 1, HB_IT_ANY ) );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user