See ChangeLog entry 19990526-13:30 EST David G. Holm <dholm@jsd-llc.com>
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
19990526-13:30 EST David G. Holm <dholm@jsd-llc.com>
|
||||
* source/rtl/dates.c
|
||||
- Added hb_dow and HARBOUR DOW() supplied by Jose Lalin <dezac@corevia.com>
|
||||
+ tests/working/dates3.prg
|
||||
- New file to test DOW() supplied by Jose Lalin <dezac@corevia.com>
|
||||
|
||||
19990526-17:25 Eddie Runia
|
||||
* tests/working/strip.prg
|
||||
delete broken one and moved working one in
|
||||
|
||||
@@ -11,6 +11,11 @@
|
||||
#define _OPTIMIZE_DTOS
|
||||
#endif
|
||||
|
||||
/*
|
||||
ADJ is 7 for ISO, 6 for no ISO
|
||||
*/
|
||||
#define ADJ 7
|
||||
|
||||
extern STACK stack;
|
||||
|
||||
long hb_dateEncode( long lDay, long lMonth, long lYear )
|
||||
@@ -448,3 +453,36 @@ oTime->tm_mday);
|
||||
_errRelease(pError);
|
||||
}
|
||||
}
|
||||
long hb_dow( long d, long m, long y )
|
||||
{
|
||||
|
||||
if( m < 3 )
|
||||
{
|
||||
m += 13;
|
||||
y--;
|
||||
}
|
||||
else
|
||||
m++;
|
||||
|
||||
return ( d + 26 * m / 10 + y + y / 4 - y / 100 + y / 400 + ADJ ) % 7;
|
||||
}
|
||||
|
||||
HARBOUR DOW( void )
|
||||
{
|
||||
PITEM pDate = _param( 1, IT_DATE );
|
||||
long lDay, lMonth, lYear;
|
||||
|
||||
if( pDate )
|
||||
{
|
||||
hb_dateDecode( pDate->value.lDate, &lDay, &lMonth, &lYear );
|
||||
_retnl( hb_dow( lDay, lMonth, lYear ) );
|
||||
stack.Return.wLength = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
PITEM pError = _errNew();
|
||||
_errPutDescription(pError, "Error BASE/1115 Argument error: DOW");
|
||||
_errLaunch(pError);
|
||||
_errRelease(pError);
|
||||
}
|
||||
}
|
||||
|
||||
39
harbour/tests/working/dates3.prg
Normal file
39
harbour/tests/working/dates3.prg
Normal file
@@ -0,0 +1,39 @@
|
||||
// Testing Harbour dates management.
|
||||
|
||||
#include "set.ch"
|
||||
|
||||
function main()
|
||||
|
||||
LOCAL dDate
|
||||
|
||||
set( _SET_DATEFORMAT, "dd/mm/yyyy" )
|
||||
dDate := cToD( "25/05/1999" )
|
||||
|
||||
OutStd( dDate, dow( dDate ), chr( 10 ) )
|
||||
|
||||
OutStd( LastMonday( dDate ), chr( 10 ) )
|
||||
|
||||
dDate += 3
|
||||
OutStd( dDate, dow( dDate ), chr( 10 ) )
|
||||
|
||||
dDate += 4
|
||||
OutStd( dDate, dow( dDate ), chr( 10 ) )
|
||||
|
||||
set( _SET_DATEFORMAT, "mm/dd/yyyy" )
|
||||
dDate := cToD( "05/25/1999" )
|
||||
|
||||
OutStd( dDate, dow( dDate ), chr( 10 ) )
|
||||
|
||||
OutStd( LastMonday( dDate ), chr( 10 ) )
|
||||
|
||||
dDate += 3
|
||||
OutStd( dDate, dow( dDate ), chr( 10 ) )
|
||||
|
||||
dDate += 4
|
||||
OutStd( dDate, dow( dDate ), chr( 10 ) )
|
||||
|
||||
return nil
|
||||
|
||||
// Like NG's sample
|
||||
function LastMonday( dDate )
|
||||
return dDate - dow( dDate ) + 2
|
||||
Reference in New Issue
Block a user