From 33dd5132f854898e584274675a48cda357f0ec29 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Sat, 14 Jul 2007 10:32:09 +0000 Subject: [PATCH] 2007-07-14 12:31 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbcompat.ch ! changed hb_adler() to hb_adler32() * harbour/contrib/libct/dattime2.c * changed WEEK() to be exactly CT3 compatible. I do not know why but in CT3 WEEK() checks if the first character of date format is 'd' or 'D' and in such case uses differ algorithm to calculate week number. --- harbour/ChangeLog | 10 ++++++++++ harbour/contrib/libct/dattime2.c | 13 ++++++++++--- harbour/include/hbcompat.ch | 4 ++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 93f0242e32..6da50cceb5 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,16 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2007-07-14 12:31 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/hbcompat.ch + ! changed hb_adler() to hb_adler32() + + * harbour/contrib/libct/dattime2.c + * changed WEEK() to be exactly CT3 compatible. I do not know why + but in CT3 WEEK() checks if the first character of date format + is 'd' or 'D' and in such case uses differ algorithm to calculate + week number. + 2007-07-11 12:04 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/mysql/tmysql.prg ! Some fixes for the previous fixes. diff --git a/harbour/contrib/libct/dattime2.c b/harbour/contrib/libct/dattime2.c index 29ac431c42..d1a2128d9b 100644 --- a/harbour/contrib/libct/dattime2.c +++ b/harbour/contrib/libct/dattime2.c @@ -93,7 +93,8 @@ static int ct_daysinmonth( int iMonth, BOOL bLeap ) static int ct_daystomonth( int iMonth, BOOL bLeap ) { - int iMonthes[] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }; + static const int iMonthes[] = + { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }; return ( ( iMonth < 1 && iMonth > 12 ) ? 0 : iMonthes[iMonth - 1] + ( ( bLeap && iMonth > 2 ) ? 1 : 0 ) ); @@ -909,7 +910,7 @@ HB_FUNC( WEEK ) int iYear, iMonth, iDay, iWeek; PHB_ITEM pDate = hb_param( 1, HB_IT_DATE ); LONG lDate = 0; - BOOL bSWN = ( ISLOG( 2 ) ? hb_parl( 2 ) : 0 ); + BOOL bSWN = ( ISLOG( 2 ) ? hb_parl( 2 ) : FALSE ); if( ISDATE( 1 ) ) { @@ -942,7 +943,13 @@ HB_FUNC( WEEK ) } else { - LONG lDate2 = lDate + 3 - ( ( hb_dateDOW( iYear, iMonth, iDay ) + 5 ) % 7 ); + LONG lDate2; + + if( hb_set.HB_SET_DATEFORMAT && ( hb_set.HB_SET_DATEFORMAT[0] == 'd' || + hb_set.HB_SET_DATEFORMAT[0] == 'D' ) ) + lDate2 = lDate + 3 - ( hb_dateDOW( iYear, iMonth, iDay ) + 5 ) % 7; + else + lDate2 = lDate + 4 - hb_dateDOW( iYear, iMonth, iDay ); iWeek = ( ct_doy( lDate2 ) - 1 ) / 7 + 1; } diff --git a/harbour/include/hbcompat.ch b/harbour/include/hbcompat.ch index 7a43d6ffc2..8210b2440b 100644 --- a/harbour/include/hbcompat.ch +++ b/harbour/include/hbcompat.ch @@ -74,7 +74,7 @@ #xtranslate hb_libFree([]) => libFree() #xtranslate hb_CStr([]) => CStr() - #xtranslate hb_checksum([]) => hb_adler() + #xtranslate hb_checksum([]) => hb_adler32() #else @@ -97,7 +97,7 @@ #xtranslate libFree([]) => hb_libFree() #xtranslate CStr([]) => hb_CStr() - #xtranslate hb_adler([]) => hb_checksum() + #xtranslate hb_adler32([]) => hb_checksum() #xtranslate HASH([]) => HB_HASH() #xtranslate HHASKEY([]) => HB_HHASKEY()