From: Adriano d. S. F. <asf...@us...> - 2005-05-07 19:30:48
|
Build Version : T2.0.0.10884 Firebird 2.0 Alpha 2 (writeBuildNum.sh,v 1.10896 2005/05/07 19:27:51 asfernandes ) Update of /cvsroot/firebird/firebird2/src/extlib/fbudf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8054/src/extlib/fbudf Modified Files: Tag: B2_0_intl fbudf.cpp fbudf.h fbudf.sql Log Message: Merge HEAD changes from Alpha1 to 2005-05-07 into B2_0_intl branch Index: fbudf.cpp =================================================================== RCS file: /cvsroot/firebird/firebird2/src/extlib/fbudf/fbudf.cpp,v retrieving revision 1.17.2.3 retrieving revision 1.17.2.4 diff -b -U3 -r1.17.2.3 -r1.17.2.4 --- fbudf.cpp 1 Nov 2004 02:02:51 -0000 1.17.2.3 +++ fbudf.cpp 7 May 2005 19:27:48 -0000 1.17.2.4 @@ -292,6 +292,7 @@ } // namespace internal +// BEGIN DEPRECATED FUNCTIONS. FBUDF_API paramdsc* idNvl(paramdsc* v, paramdsc* v2) { if (!internal::isnull(v)) @@ -370,6 +371,7 @@ internal::set_string_type(rc, len, sv); return; } +// END DEPRECATED FUNCTIONS. namespace internal { @@ -475,15 +477,14 @@ ++times.tm_year; times.tm_mon -= 12; } - else if (times.tm_mon < 1) + else if (times.tm_mon < 0) { --times.tm_year; times.tm_mon += 12; } - int md[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; const int ly = times.tm_year + 1900; - if (ly % 4 == 0 && ly % 100 != 0 || ly % 400 == 0) - ++md[1]; + const bool leap = ly % 4 == 0 && ly % 100 != 0 || ly % 400 == 0; + const int md[] = {31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; if (times.tm_mday > md[times.tm_mon]) times.tm_mday = md[times.tm_mon]; isc_encode_timestamp(×, v); @@ -576,6 +577,14 @@ return; } +FBUDF_API int isLeapYear(const ISC_TIMESTAMP* v) +{ + tm times; + isc_decode_timestamp(v, ×); + const int ly = times.tm_year + 1900; + return ly % 4 == 0 && ly % 100 != 0 || ly % 400 == 0; +} + FBUDF_API void fbtruncate(const paramdsc* v, paramdsc* rc) { if (internal::isnull(v)) Index: fbudf.h =================================================================== RCS file: /cvsroot/firebird/firebird2/src/extlib/fbudf/fbudf.h,v retrieving revision 1.5.2.2 retrieving revision 1.5.2.3 diff -b -U3 -r1.5.2.2 -r1.5.2.3 --- fbudf.h 1 Nov 2004 02:02:52 -0000 1.5.2.2 +++ fbudf.h 7 May 2005 19:27:49 -0000 1.5.2.3 @@ -50,12 +50,14 @@ #endif +// BEGIN DEPRECATED FUNCTIONS. FBUDF_API paramdsc* idNvl(paramdsc* v, paramdsc* v2); FBUDF_API void sNvl(const paramdsc* v, const paramdsc* v2, paramdsc* rc); FBUDF_API paramdsc* iNullIf(paramdsc* v, paramdsc* v2); FBUDF_API paramdsc* dNullIf(paramdsc* v, paramdsc* v2); FBUDF_API void sNullIf(const paramdsc* v, const paramdsc* v2, paramdsc* rc); +// END DEPRECATED FUNCTIONS. FBUDF_API void DOW(const ISC_TIMESTAMP* v, char* rc); FBUDF_API void SDOW(const ISC_TIMESTAMP* v, char* rc); @@ -75,6 +77,8 @@ FBUDF_API void getExactTimestamp(ISC_TIMESTAMP* rc); +FBUDF_API int isLeapYear(const ISC_TIMESTAMP* v); + FBUDF_API void fbtruncate(const paramdsc* v, paramdsc* rc); FBUDF_API void fbround(const paramdsc* v, paramdsc* rc); FBUDF_API void power(const paramdsc* v, const paramdsc* v2, paramdsc* rc); Index: fbudf.sql =================================================================== RCS file: /cvsroot/firebird/firebird2/src/extlib/fbudf/fbudf.sql,v retrieving revision 1.5.2.2 retrieving revision 1.5.2.3 diff -b -U3 -r1.5.2.2 -r1.5.2.3 --- fbudf.sql 1 Nov 2004 02:02:52 -0000 1.5.2.2 +++ fbudf.sql 7 May 2005 19:27:49 -0000 1.5.2.3 @@ -149,9 +149,16 @@ --It will work only with Win32 until it's ported to another OS. --FBUDF_API ISC_TIMESTAMP* getExactTimestamp(ISC_TIMESTAMP* rc) declare external function getExactTimestamp -timestamp returns parameter 1 +timestamp +returns parameter 1 entry_point 'getExactTimestamp' module_name 'fbudf'; +--FBUDF_API int isLeapYear(const ISC_TIMESTAMP* v); +declare external function isLeapYear +timestamp +returns int by value +entry_point 'isLeapYear' module_name 'fbudf'; + --FBUDF_API paramdsc* fbtruncate(paramdsc* v, paramdsc* rc) declare external function Truncate int by descriptor, int by descriptor |