[INTERPRETER]

* BUG: DateDiff() correctly returns zero when asking for the number of days between two timestamps having the same date.



git-svn-id: svn://localhost/gambas/trunk@7612 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2016-02-25 23:09:51 +00:00
parent 61064b6f6e
commit 056190b68d

View file

@ -764,10 +764,14 @@ int DATE_diff(VALUE *date1, VALUE *date2, int period)
{ {
case DP_DAY: case DP_DAY:
case DP_WEEK: case DP_WEEK:
fprintf(stderr, "DATE_diff: (%d %d) -> (%d %d)\n", date2->_date.date, date2->_date.time, date1->_date.date, date1->_date.time);
diff = date1->_date.date - date2->_date.date; diff = date1->_date.date - date2->_date.date;
if (diff)
{
sdiff = lsgn(date1->_date.time - date2->_date.time); sdiff = lsgn(date1->_date.time - date2->_date.time);
if (sdiff != lsgn(diff)) if (sdiff != lsgn(diff))
diff += sdiff; diff += sdiff;
}
break; break;
case DP_MILLISECOND: case DP_MILLISECOND:
@ -787,9 +791,12 @@ int DATE_diff(VALUE *date1, VALUE *date2, int period)
case DP_WEEKDAY: case DP_WEEKDAY:
diff = date1->_date.date - date2->_date.date; diff = date1->_date.date - date2->_date.date;
if (diff)
{
sdiff = lsgn(date1->_date.time - date2->_date.time); sdiff = lsgn(date1->_date.time - date2->_date.time);
if (sdiff != lsgn(diff)) if (sdiff != lsgn(diff))
diff += sdiff; diff += sdiff;
}
ds1 = *DATE_split(date1); ds1 = *DATE_split(date1);
ds2 = *DATE_split(date2); ds2 = *DATE_split(date2);
break; break;