[GB.DB.POSTGRESQL]

* BUG: Gambas date/time values without date is now stored as the minimum
  possible date that PostgreSQL accepts, '4713-01-01 BC'.


git-svn-id: svn://localhost/gambas/trunk@7506 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2015-12-06 00:12:15 +00:00
parent fca1fb8e0e
commit 18ac7691c3

View file

@ -456,6 +456,11 @@ static void conv_data(const char *data, int len, GB_VARIANT_VALUE *val, Oid type
if (bc)
date.year = (-date.year);
// 4713-01-01 BC is used for null dates
if (date.year == -4713 && date.month == 1 && date.day == 1)
date.year = date.month = date.day = 0;
GB.MakeDate(&date, (GB_DATE *)&conv);
val->type = GB_T_DATE;
@ -867,9 +872,13 @@ static int format_value(GB_VALUE *arg, DB_FORMAT_CALLBACK add)
date = GB.SplitDate((GB_DATE *)arg);
// Gambas year is between -4801 and +9999
// PostgreSQL year is between -4713 and +294276
// So let's use -4713 for representing null dates.
if (date->year == 0)
{
l = sprintf(_buffer, "'%02d:%02d:%02d'", date->hour, date->min, date->sec);
l = sprintf(_buffer, "'4713-01-01 %02d:%02d:%02d BC'", date->hour, date->min, date->sec);
add(_buffer, l);
}
else