Skip to content

Commit

Permalink
Use OGR_F_GetFieldAsISO8601DateTime for GDAL >= 3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
pramsey committed Dec 8, 2023
1 parent 30898f5 commit bab22af
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ogr_fdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1953,14 +1953,14 @@ ogrFeatureToSlot(const OGRFeatureH feat, TupleTableSlot* slot, const OgrFdwExecS
case OFTTime:
case OFTDateTime:
{
#if (GDAL_VERSION_NUM < GDAL_COMPUTE_VERSION(3,7,0))
/*
* OGR date/times have a weird access method, so we use that to pull
* out the raw data and turn it into a string for PgSQL's (very
* sophisticated) date/time parsing routines to handle.
*/
int year, month, day, hour, minute, second, tz;
char cstr[256];

OGR_F_GetFieldAsDateTime(feat, ogrfldnum,
&year, &month, &day,
&hour, &minute, &second, &tz);
Expand All @@ -1977,6 +1977,9 @@ ogrFeatureToSlot(const OGRFeatureH feat, TupleTableSlot* slot, const OgrFdwExecS
{
snprintf(cstr, 256, "%d-%02d-%02d %02d:%02d:%02d", year, month, day, hour, minute, second);
}
#else
const char* cstr = OGR_F_GetFieldAsISO8601DateTime(feat, ogrfldnum, NULL);
#endif
nulls[i] = false;
values[i] = pgDatumFromCString(cstr, pgtype, pgtypmod, pginputfunc);
break;
Expand Down

0 comments on commit bab22af

Please sign in to comment.