From 0a8f1d9072461cd460e661c0bda0b3827d005c8b Mon Sep 17 00:00:00 2001 From: Adrien Prokopowicz Date: Fri, 14 Aug 2015 09:57:54 +0000 Subject: [PATCH] [INTERPRETER] * BUG: Fix DateDiff() day comparison when comparing two dates with different times. git-svn-id: svn://localhost/gambas/trunk@7224 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- main/gbx/gbx_date.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/main/gbx/gbx_date.c b/main/gbx/gbx_date.c index a07fccdbe..5d7922a81 100644 --- a/main/gbx/gbx_date.c +++ b/main/gbx/gbx_date.c @@ -764,9 +764,9 @@ int DATE_diff(VALUE *date1, VALUE *date2, int period) case DP_DAY: case DP_WEEK: diff = date1->_date.date - date2->_date.date; - sdiff = lsgn(diff); - if (sdiff != lsgn(date1->_date.time - date2->_date.time)) - diff -= sdiff; + sdiff = lsgn(date1->_date.time - date2->_date.time); + if (sdiff != lsgn(diff)) + diff += sdiff; break; case DP_MILLISECOND: @@ -786,9 +786,9 @@ int DATE_diff(VALUE *date1, VALUE *date2, int period) case DP_WEEKDAY: diff = date1->_date.date - date2->_date.date; - sdiff = lsgn(diff); - if (sdiff != lsgn(date1->_date.time - date2->_date.time)) - diff -= sdiff; + sdiff = lsgn(date1->_date.time - date2->_date.time); + if (sdiff != lsgn(diff)) + diff += sdiff; ds1 = *DATE_split(date1); ds2 = *DATE_split(date2); break;