diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 73926e81b8..629d154186 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,76 +17,91 @@ past entries belonging to these authors: Viktor Szakats. */ +2009-05-26 02:54 UTC+0200 Viktor Szakats (harbour.01 syenar hu) + * contrib/xhb/Makefile + + contrib/xhb/datesxhb.c + + Added these xhb compatibility functions: + TSSECS(), TIMEOFDAY(), HMS2D(), TTOD(). + Borrowed from xhb, work of Giancarlo Niccolai, Walter Negro, + with few changes. + + * contrib/xhb/hbcompat.ch + + Added translation for these functions: + DATETIME(), HOUR(), MINUTE(), TTOS(), STOT(), TTOC(), CTOT() + (NOTE: I don't know if the workings of corresponding Harbour + functions are fully compatible. If not we can add + xhb_*() flavours locally in xhb lib) + 2009-05-26 02:14 UTC+0200 Viktor Szakats (harbour.01 syenar hu) - * contrib/xhb/fparse.c - * contrib/rddsql/sddmy/mysqldd.c - * contrib/rddsql/sqlbase.c - * contrib/rddsql/sqlmix.c - * contrib/rddads/adsx.c - * contrib/examples/terminal/trm_client.prg - * source/rdd/dbfnsx/dbfnsx1.c - % "" -> NULL where applicable (hb_retc*(), hb_retds(), hb_itemPutC*(), - hb_arraySetC*(), hb_errInternal(), hb_itemPutDS(), hb_arraySetDS()) + * contrib/xhb/fparse.c + * contrib/rddsql/sddmy/mysqldd.c + * contrib/rddsql/sqlbase.c + * contrib/rddsql/sqlmix.c + * contrib/rddads/adsx.c + * contrib/examples/terminal/trm_client.prg + * source/rdd/dbfnsx/dbfnsx1.c + % "" -> NULL where applicable (hb_retc*(), hb_retds(), hb_itemPutC*(), + hb_arraySetC*(), hb_errInternal(), hb_itemPutDS(), hb_arraySetDS()) - * contrib/hbqt/hbqt_qtextdocument.cpp - * contrib/hbqt/hbqt_qgridlayout.cpp - * contrib/hbqt/hbqt_qpainter.cpp - * contrib/hbqt/hbqt_qeventloop.cpp - * contrib/hbqt/hbqt_qicon.cpp - * contrib/hbqt/hbqt_qtreeview.cpp - * contrib/hbqt/hbqt_qtextline.cpp - * contrib/hbqt/hbqt_qdesktopwidget.cpp - * contrib/hbqt/hbqt_qhttp.cpp - * contrib/hbqt/hbqt_qlineedit.cpp - * contrib/hbqt/hbqt_qcombobox.cpp - * contrib/hbqt/hbqt_qlistwidget.cpp - * contrib/hbqt/hbqt_qtextcursor.cpp - * contrib/hbqt/hbqt_qtextlayout.cpp - * contrib/hbqt/hbqt_qftp.cpp - * contrib/hbqt/hbqt_qclipboard.cpp - * contrib/hbqt/hbqt_qurl.cpp - * contrib/hbqt/hbqt_qwebpage.cpp - * contrib/hbqt/hbqt_qtextedit.cpp - * contrib/hbqt/hbqt_qpixmap.cpp - * contrib/hbqt/hbqt_qsplashscreen.cpp - * contrib/hbqt/hbqt_qtablewidget.cpp - * contrib/hbqt/hbqt_qtreewidget.cpp - * contrib/hbqt/generator/hbqtgen.prg - * contrib/hbqt/hbqt_qfont.cpp - * contrib/hbqt/hbqt_qmainwindow.cpp - * contrib/hbqt/hbqt_qdir.cpp - * contrib/hbqt/hbqt_qwidget.cpp - * contrib/hbqt/hbqt_qstyle.cpp - * contrib/hbqt/hbqt_qabstractbutton.cpp - * contrib/hbqt/hbqt_qobject.cpp - * contrib/hbqt/hbqt_qcolor.cpp - * contrib/hbqt/hbqt_qtextstream.cpp - * contrib/hbqt/hbqt_qwebview.cpp - * contrib/hbqt/hbqt_qboxlayout.cpp - * contrib/hbqt/hbqt_qstatusbar.cpp - * contrib/hbqt/hbqt_qtabwidget.cpp - * contrib/hbqt/hbqt_qscrollarea.cpp - * contrib/hbqt/hbqt_qtextcharformat.cpp - ! Fixed to use HB_ISNUM() instead of HB_ISNIL(). - % Don't call HB_ISNUM() where the default value is - zero anyway. hb_parn*() functions will return zero - anyway. (well, maybe this exploits the array-type - bug in our Extend API.) + * contrib/hbqt/hbqt_qtextdocument.cpp + * contrib/hbqt/hbqt_qgridlayout.cpp + * contrib/hbqt/hbqt_qpainter.cpp + * contrib/hbqt/hbqt_qeventloop.cpp + * contrib/hbqt/hbqt_qicon.cpp + * contrib/hbqt/hbqt_qtreeview.cpp + * contrib/hbqt/hbqt_qtextline.cpp + * contrib/hbqt/hbqt_qdesktopwidget.cpp + * contrib/hbqt/hbqt_qhttp.cpp + * contrib/hbqt/hbqt_qlineedit.cpp + * contrib/hbqt/hbqt_qcombobox.cpp + * contrib/hbqt/hbqt_qlistwidget.cpp + * contrib/hbqt/hbqt_qtextcursor.cpp + * contrib/hbqt/hbqt_qtextlayout.cpp + * contrib/hbqt/hbqt_qftp.cpp + * contrib/hbqt/hbqt_qclipboard.cpp + * contrib/hbqt/hbqt_qurl.cpp + * contrib/hbqt/hbqt_qwebpage.cpp + * contrib/hbqt/hbqt_qtextedit.cpp + * contrib/hbqt/hbqt_qpixmap.cpp + * contrib/hbqt/hbqt_qsplashscreen.cpp + * contrib/hbqt/hbqt_qtablewidget.cpp + * contrib/hbqt/hbqt_qtreewidget.cpp + * contrib/hbqt/generator/hbqtgen.prg + * contrib/hbqt/hbqt_qfont.cpp + * contrib/hbqt/hbqt_qmainwindow.cpp + * contrib/hbqt/hbqt_qdir.cpp + * contrib/hbqt/hbqt_qwidget.cpp + * contrib/hbqt/hbqt_qstyle.cpp + * contrib/hbqt/hbqt_qabstractbutton.cpp + * contrib/hbqt/hbqt_qobject.cpp + * contrib/hbqt/hbqt_qcolor.cpp + * contrib/hbqt/hbqt_qtextstream.cpp + * contrib/hbqt/hbqt_qwebview.cpp + * contrib/hbqt/hbqt_qboxlayout.cpp + * contrib/hbqt/hbqt_qstatusbar.cpp + * contrib/hbqt/hbqt_qtabwidget.cpp + * contrib/hbqt/hbqt_qscrollarea.cpp + * contrib/hbqt/hbqt_qtextcharformat.cpp + ! Fixed to use HB_ISNUM() instead of HB_ISNIL(). + % Don't call HB_ISNUM() where the default value is + zero anyway. hb_parn*() functions will return zero + anyway. (well, maybe this exploits the array-type + bug in our Extend API.) - * contrib/gtwvg/wvgwin.c - * contrib/gtwvg/wvgsink.c - * Avoiding ISNIL(). Corrected just a few occurences. - This practice is still wrong in most of the cases in - GTWVG code, so if the goal is GPF-free and consitently - behaving apps, these would better be fixed. With - string params ISNIL() is either superfluous or simply - don't protect agains GPFs, for rest of the cases it - either causes unexpected defaults (zero), or simply - superfluous for the rest of the cases. IOW: Avoid it, - use HB_ISNUM(), HB_ISCHAR() / parcx() instead. + * contrib/gtwvg/wvgwin.c + * contrib/gtwvg/wvgsink.c + * Avoiding ISNIL(). Corrected just a few occurences. + This practice is still wrong in most of the cases in + GTWVG code, so if the goal is GPF-free and consitently + behaving apps, these would better be fixed. With + string params ISNIL() is either superfluous or simply + don't protect agains GPFs, for rest of the cases it + either causes unexpected defaults (zero), or simply + superfluous for the rest of the cases. IOW: Avoid it, + use HB_ISNUM(), HB_ISCHAR() / parcx() instead. - * contrib/hbgd/gdwrp.c - * Formatting. + * contrib/hbgd/gdwrp.c + * Formatting. 2009-05-25 15:01 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * contrib/gtwvg/wvgsink.c diff --git a/harbour/contrib/xhb/Makefile b/harbour/contrib/xhb/Makefile index 2fd354bc16..5e6cae1748 100644 --- a/harbour/contrib/xhb/Makefile +++ b/harbour/contrib/xhb/Makefile @@ -8,6 +8,7 @@ LIBNAME=xhb C_SOURCES=\ cstructc.c \ + datesxhb.c \ dbf2txt.c \ dbgfxc.c \ filestat.c \ diff --git a/harbour/contrib/xhb/datesxhb.c b/harbour/contrib/xhb/datesxhb.c new file mode 100644 index 0000000000..89a6408abf --- /dev/null +++ b/harbour/contrib/xhb/datesxhb.c @@ -0,0 +1,120 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * The Date API (Harbour level) + * + * Copyright 1999-2001 Viktor Szakats + * Copyright 2004 Giancarlo Niccolai + * Copyright 2007 Walter Negro + * 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 "hbapierr.h" +#include "hbdate.h" + +/* NOTE: szTime must be 9 chars large. */ + +static ULONG hb_TimeStrToSec( char * pszTime ) +{ + ULONG ulLen; + ULONG ulTime = 0; + + HB_TRACE(HB_TR_DEBUG, ("hb_TimeStrToSec(%s)", pszTime)); + + ulLen = strlen( pszTime ); + + if( ulLen >= 1 ) + ulTime += ( ULONG ) hb_strVal( pszTime, ulLen ) * 3600; + + if( ulLen >= 4 ) + ulTime += ( ULONG ) hb_strVal( pszTime + 3, ulLen - 3 ) * 60; + + if( ulLen >= 7 ) + ulTime += ( ULONG ) hb_strVal( pszTime + 6, ulLen - 6 ); + + return ulTime; +} + +HB_FUNC( TSSECS ) +{ + hb_retnl( hb_TimeStrToSec( hb_parcx( 1 ) ) ); +} + +HB_FUNC( TIMEOFDAY ) +{ + char szResult[ 9 ]; + + if( hb_pcount() == 0 ) + { + hb_dateTimeStr( szResult ); + } + else + { + int iSeconds = hb_parni(1); + iSeconds %= 3600*24; + hb_snprintf( szResult, sizeof( szResult ), "%02d:%02d:%02d", + iSeconds/3600 , (iSeconds % 3600)/60, iSeconds % 60 ); + } + hb_retclen( szResult, 8 ); +} + +HB_FUNC( HMS2D ) +{ + int iHour = hb_parni( 1 ); + int iMin = hb_parni( 2 ); + double dSec = hb_parnd( 3 ); + + hb_retnd( hb_timeEncode( iHour, iMin, ( int ) dSec, ( int ) ( ( ( double ) ( dSec - ( double ) ( ( int ) dSec ) ) ) * 1000 ) ) ); +} + +HB_FUNC( TTOD ) +{ + if( ISDATE( 1 ) ) + hb_retdl( hb_pardl( 1 ) ); + else + hb_errRT_BASE_SubstR( EG_ARG, 1120, NULL, HB_ERR_FUNCNAME, 1, hb_paramError( 1 ) ); +} diff --git a/harbour/contrib/xhb/hbcompat.ch b/harbour/contrib/xhb/hbcompat.ch index 81c3b92ee3..deea53b182 100644 --- a/harbour/contrib/xhb/hbcompat.ch +++ b/harbour/contrib/xhb/hbcompat.ch @@ -111,6 +111,14 @@ #xtranslate hb_ADel([]) => ADel() #xtranslate hb_At([]) => At() + #xtranslate hb_DateTime() => DateTime() + #xtranslate hb_Hour([]) => Hour() + #xtranslate hb_Minute([]) => Minute() + #xtranslate hb_TToS([]) => TToS() + #xtranslate hb_SToT([]) => SToT() + #xtranslate hb_TToC([]) => TToC() + #xtranslate hb_CToT([]) => CToT() + #xtranslate hb_GetEnv([]) => GetEnv() #xtranslate hb_SetKey([]) => SetKey() @@ -216,6 +224,14 @@ #xtranslate ADel(,,) => hb_ADel(,,) #xtranslate At(,,[]) => hb_At(,,) + #xtranslate DateTime() => hb_DateTime() + #xtranslate Hour([]) => hb_Hour() + #xtranslate Minute([]) => hb_Minute() + #xtranslate TToS([]) => hb_TToS() + #xtranslate SToT([]) => hb_SToT() + #xtranslate TToC([]) => hb_TToC() + #xtranslate CToT([]) => hb_CToT() + #xtranslate GetEnv([]) => hb_GetEnv() #xtranslate SetKey([]) => hb_SetKey() #xtranslate MemoWrit(,,) => iif( hb_isLogical() .AND. , MemoWrit(,), hb_MemoWrit(,) )