2009-03-22 22:13 UTC+0100 Francesco Saverio Giudice (info/at/fsgiudice.com)
+ harbour/source/rtl/tscalart.c
+ Added scalar TIMESTAMP
* harbour/source/rtl/Makefile
+ tscalart.c added
* harbour/include/hbclass.ch
* added HBTIMESTAMP scalar type to ENABLE TYPE CLASS
* harbour/source/rtl/tscalar.prg
+ added scalar class TIMESTAMP with methods to extract
parts from Timestamp:
Date(), Time(), Year(), Month(), Day(), Hour(), Minute(), Sec()
* added methods Year(), Month(), Day() to Date scalar class
* harbour/contrib/hbwin/win_ole.c
* updated for new Timestamp type
This commit is contained in:
@@ -8,6 +8,21 @@
|
||||
2009-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org)
|
||||
*/
|
||||
|
||||
2009-03-22 22:13 UTC+0100 Francesco Saverio Giudice (info/at/fsgiudice.com)
|
||||
+ harbour/source/rtl/tscalart.c
|
||||
+ Added scalar TIMESTAMP
|
||||
* harbour/source/rtl/Makefile
|
||||
+ tscalart.c added
|
||||
* harbour/include/hbclass.ch
|
||||
* added HBTIMESTAMP scalar type to ENABLE TYPE CLASS
|
||||
* harbour/source/rtl/tscalar.prg
|
||||
+ added scalar class TIMESTAMP with methods to extract
|
||||
parts from Timestamp:
|
||||
Date(), Time(), Year(), Month(), Day(), Hour(), Minute(), Sec()
|
||||
* added methods Year(), Month(), Day() to Date scalar class
|
||||
* harbour/contrib/hbwin/win_ole.c
|
||||
* updated for new Timestamp type
|
||||
|
||||
2009-03-22 21:54 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/source/rtl/valtoexp.prg
|
||||
+ added timestamp support to hb_valToExp() and hb_cStr() functions
|
||||
|
||||
@@ -306,6 +306,8 @@ void hb_oleItemToVariant( VARIANT *pVariant, PHB_ITEM pItem )
|
||||
|
||||
VariantClear( pVariant );
|
||||
|
||||
hb_ToOutDebug( "\n\rhb_itemType( pItem ) =%i\n\r", hb_itemType( pItem ) );
|
||||
|
||||
switch( hb_itemType( pItem ) )
|
||||
{
|
||||
case HB_IT_NIL:
|
||||
@@ -429,6 +431,8 @@ void hb_oleItemToVariant( VARIANT *pVariant, PHB_ITEM pItem )
|
||||
{
|
||||
long lDate = hb_itemGetDL( pItem );
|
||||
|
||||
hb_ToOutDebug( "Sono in HB_IT_DATE" );
|
||||
|
||||
if( lDate == 0 )
|
||||
pVariant->n1.n2.vt = VT_NULL;
|
||||
else if( bByRef )
|
||||
@@ -446,6 +450,30 @@ void hb_oleItemToVariant( VARIANT *pVariant, PHB_ITEM pItem )
|
||||
}
|
||||
break;
|
||||
|
||||
case HB_IT_TIMESTAMP:
|
||||
{
|
||||
double dDateTime = hb_itemGetTD( pItem );
|
||||
|
||||
hb_ToOutDebug( "Sono in HB_IT_TIMESTAMP" );
|
||||
|
||||
if( dDateTime == 0 )
|
||||
pVariant->n1.n2.vt = VT_NULL;
|
||||
|
||||
else if( bByRef )
|
||||
{
|
||||
hb_itemPutND( pItem, ( dDateTime - (double) 2415019 ) );
|
||||
|
||||
pVariant->n1.n2.vt = VT_BYREF | VT_DATE;
|
||||
pVariant->n1.n2.n3.pdblVal = &( pItem->item.asDouble.value );
|
||||
}
|
||||
else
|
||||
{
|
||||
pVariant->n1.n2.vt = VT_DATE;
|
||||
pVariant->n1.n2.n3.dblVal = ( dDateTime - (double) 2415019 );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case HB_IT_POINTER:
|
||||
pVariant->n1.n2.vt = VT_PTR;
|
||||
pVariant->n1.n2.n3.byref = hb_itemGetPtr( pItem );
|
||||
@@ -803,11 +831,11 @@ static void FreeParams( DISPPARAMS *pDispParams, PHB_ITEM *aPrgParams )
|
||||
break;
|
||||
|
||||
case VT_BYREF | VT_DATE:
|
||||
hb_itemPutDL( pItem, ( long ) ( *( pVariant->n1.n2.n3.pdblVal ) ) + 2415019 );
|
||||
hb_itemPutTD( pItem, *pVariant->n1.n2.n3.pdblVal + ( double ) 2415019 );
|
||||
break;
|
||||
|
||||
case VT_DATE:
|
||||
hb_itemPutDL( pItem, ( long ) ( pVariant->n1.n2.n3.dblVal ) + 2415019 );
|
||||
hb_itemPutTD( pItem, pVariant->n1.n2.n3.dblVal + ( double ) 2415019 );
|
||||
break;
|
||||
|
||||
case VT_BYREF | VT_EMPTY:
|
||||
@@ -1185,11 +1213,11 @@ HRESULT hb_oleVariantToItem( PHB_ITEM pItem, VARIANT *pVariant )
|
||||
}
|
||||
|
||||
case VT_DATE | VT_BYREF:
|
||||
hb_itemPutDL( pItem, ( long ) ( *pVariant->n1.n2.n3.pdblVal ) + 2415019 );
|
||||
hb_itemPutTD( pItem, *pVariant->n1.n2.n3.pdblVal + ( double ) 2415019 );
|
||||
break;
|
||||
|
||||
case VT_DATE:
|
||||
hb_itemPutDL( pItem, ( long ) ( pVariant->n1.n2.n3.dblVal ) + 2415019 );
|
||||
hb_itemPutTD( pItem, pVariant->n1.n2.n3.dblVal + ( double ) 2415019 );
|
||||
break;
|
||||
|
||||
case VT_EMPTY | VT_BYREF:
|
||||
|
||||
@@ -590,13 +590,13 @@ DECLARE HBClass ;
|
||||
__clsAssocType( __clsInstSuper( @<ClassFuncName>() ), #<type> )
|
||||
|
||||
#command ENABLE TYPE CLASS <type: ;
|
||||
ARRAY, BLOCK, CHARACTER, DATE, HASH, LOGICAL, NIL, NUMERIC, SYMBOL, POINTER> ;
|
||||
ARRAY, BLOCK, CHARACTER, DATE, HASH, LOGICAL, NIL, NUMERIC, SYMBOL, TIMESTAMP, POINTER> ;
|
||||
[, <typeN: ;
|
||||
ARRAY, BLOCK, CHARACTER, DATE, HASH, LOGICAL, NIL, NUMERIC, SYMBOL, POINTER>] => ;
|
||||
ARRAY, BLOCK, CHARACTER, DATE, HASH, LOGICAL, NIL, NUMERIC, SYMBOL, TIMESTAMP, POINTER>] => ;
|
||||
REQUEST HB<type> [, HB<typeN>]
|
||||
|
||||
#command ENABLE TYPE CLASS ALL => ;
|
||||
REQUEST HBArray, HBBlock, HBCharacter, HBDate, HBHash, ;
|
||||
HBLogical, HBNil, HBNumeric, HBSymbol, HBPointer
|
||||
HBLogical, HBNil, HBNumeric, HBSymbol, HBTimeStamp, HBPointer
|
||||
|
||||
#endif /* HB_CLASS_CH_ */
|
||||
|
||||
@@ -158,6 +158,7 @@ C_SOURCES=\
|
||||
tscalarn.c \
|
||||
tscalarp.c \
|
||||
tscalars.c \
|
||||
tscalart.c \
|
||||
tscalaru.c \
|
||||
type.c \
|
||||
val.c \
|
||||
|
||||
@@ -82,6 +82,7 @@ METHOD AsString() CLASS ScalarObject
|
||||
CASE "M"
|
||||
CASE "C" ; RETURN Self
|
||||
CASE "D" ; RETURN DToC( Self )
|
||||
CASE "T" ; RETURN HB_TToC( Self )
|
||||
CASE "H" ; RETURN "{ ... => ... }"
|
||||
CASE "L" ; RETURN iif( Self, ".T.", ".F." )
|
||||
CASE "N" ; RETURN hb_NToS( Self )
|
||||
@@ -98,6 +99,7 @@ METHOD AsExpStr() CLASS ScalarObject
|
||||
CASE "M"
|
||||
CASE "C" ; RETURN '"' + Self + '"'
|
||||
CASE "D" ; RETURN 'CToD("' + DToC( Self ) + '")'
|
||||
CASE "T" ; RETURN 'HB_CToT("' + HB_TToC( Self ) + '")'
|
||||
ENDSWITCH
|
||||
|
||||
RETURN ::AsString()
|
||||
@@ -271,6 +273,9 @@ METHOD AsExpStr() CLASS Character
|
||||
|
||||
CREATE CLASS Date INHERIT HBScalar FUNCTION __HBDate
|
||||
|
||||
METHOD Year()
|
||||
METHOD Month()
|
||||
METHOD Day()
|
||||
METHOD AsString()
|
||||
METHOD AsExpStr()
|
||||
|
||||
@@ -282,6 +287,63 @@ METHOD AsString() CLASS Date
|
||||
METHOD AsExpStr() CLASS Date
|
||||
RETURN 'CToD("' + ::AsString() + '")'
|
||||
|
||||
METHOD Year() CLASS Date
|
||||
RETURN Year( Self )
|
||||
|
||||
METHOD Month() CLASS Date
|
||||
RETURN Month( Self )
|
||||
|
||||
METHOD Day() CLASS Date
|
||||
RETURN Day( Self )
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
CREATE CLASS TimeStamp INHERIT HBScalar FUNCTION __HBTimeStamp
|
||||
|
||||
METHOD Date()
|
||||
METHOD Time()
|
||||
METHOD Year()
|
||||
METHOD Month()
|
||||
METHOD Day()
|
||||
METHOD Hour()
|
||||
METHOD Minute()
|
||||
METHOD Sec()
|
||||
|
||||
METHOD AsString()
|
||||
METHOD AsExpStr()
|
||||
|
||||
ENDCLASS
|
||||
|
||||
METHOD AsString() CLASS TimeStamp
|
||||
RETURN HB_TTOS( Self )
|
||||
|
||||
METHOD AsExpStr() CLASS TimeStamp
|
||||
RETURN 'HB_STOT("' + ::AsString() + '")'
|
||||
|
||||
METHOD Date() CLASS TimeStamp
|
||||
RETURN HB_TTOC( Self, NIL, "" )
|
||||
|
||||
METHOD Time() CLASS TimeStamp
|
||||
RETURN HB_TTOC( Self, "", "HH:MM:SS" )
|
||||
|
||||
METHOD Year() CLASS TimeStamp
|
||||
RETURN Year( Self )
|
||||
|
||||
METHOD Month() CLASS TimeStamp
|
||||
RETURN Month( Self )
|
||||
|
||||
METHOD Day() CLASS TimeStamp
|
||||
RETURN Day( Self )
|
||||
|
||||
METHOD Hour() CLASS TimeStamp
|
||||
RETURN HB_HOUR( Self )
|
||||
|
||||
METHOD Minute() CLASS TimeStamp
|
||||
RETURN HB_MINUTE( Self )
|
||||
|
||||
METHOD Sec() CLASS TimeStamp
|
||||
RETURN HB_SEC( Self )
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
CREATE CLASS Hash INHERIT HBScalar FUNCTION __HBHash
|
||||
|
||||
73
harbour/source/rtl/tscalart.c
Normal file
73
harbour/source/rtl/tscalart.c
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* Date scalar class function
|
||||
*
|
||||
* Copyright 2007 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
||||
* www - http://www.harbour-project.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
|
||||
*
|
||||
* As a special exception, the Harbour Project gives permission for
|
||||
* additional uses of the text contained in its release of Harbour.
|
||||
*
|
||||
* The exception is that, if you link the Harbour libraries with other
|
||||
* files to produce an executable, this does not by itself cause the
|
||||
* resulting executable to be covered by the GNU General Public License.
|
||||
* Your use of that executable is in no way restricted on account of
|
||||
* linking the Harbour library code into it.
|
||||
*
|
||||
* This exception does not however invalidate any other reasons why
|
||||
* the executable file might be covered by the GNU General Public License.
|
||||
*
|
||||
* This exception applies only to the code released by the Harbour
|
||||
* Project under the name Harbour. If you copy code from other
|
||||
* Harbour Project or Free Software Foundation releases into a copy of
|
||||
* Harbour, as the General Public License permits, the exception does
|
||||
* not apply to the code that you add in this way. To avoid misleading
|
||||
* anyone as to the status of such modified files, you must delete
|
||||
* this exception notice from them.
|
||||
*
|
||||
* If you write modifications of your own for Harbour, it is your choice
|
||||
* whether to permit this exception to apply to your modifications.
|
||||
* If you do not wish that, delete this exception notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbvm.h"
|
||||
|
||||
HB_FUNC_EXTERN( __HBTIMESTAMP );
|
||||
|
||||
HB_FUNC( HBTIMESTAMP )
|
||||
{
|
||||
HB_FUNC_EXEC( __HBTIMESTAMP );
|
||||
|
||||
if( hb_vmRequestQuery() == 0 )
|
||||
{
|
||||
PHB_ITEM pItem = hb_param( -1, HB_IT_ANY );
|
||||
|
||||
if( HB_IS_OBJECT( pItem ) )
|
||||
{
|
||||
hb_vmPushDynSym( hb_dynsymGetCase( "NEW" ) );
|
||||
hb_vmPush( pItem );
|
||||
hb_vmSend( 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user