626 buf = palloc(MAXDATELEN + 1);
635 date = DatumGetDateADT(
value);
638 if (DATE_NOT_FINITE(date))
639 EncodeSpecialDate(date, buf);
642 j2date(date + POSTGRES_EPOCH_JDATE,
643 &(tm.tm_year), &(tm.tm_mon), &(tm.tm_mday));
644 EncodeDateOnly(&tm, USE_XSD_DATES, buf);
650 TimeADT time = DatumGetTimeADT(
value);
657 EncodeTimeOnly(tm, fsec,
false, 0, USE_XSD_DATES, buf);
662 TimeTzADT *time = DatumGetTimeTzADTP(
value);
670 EncodeTimeOnly(tm, fsec,
true, tz, USE_XSD_DATES, buf);
679 timestamp = DatumGetTimestamp(
value);
681 if (TIMESTAMP_NOT_FINITE(timestamp))
682 EncodeSpecialTimestamp(timestamp, buf);
683 else if (timestamp2tm(timestamp, NULL, &tm, &fsec, NULL, NULL) == 0)
684 EncodeDateTime(&tm, fsec,
false, 0, NULL, USE_XSD_DATES, buf);
687 (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
688 errmsg(
"timestamp out of range")));
693 TimestampTz timestamp;
697 const char *tzn = NULL;
699 timestamp = DatumGetTimestampTz(
value);
701 if (TIMESTAMP_NOT_FINITE(timestamp))
702 EncodeSpecialTimestamp(timestamp, buf);
703 else if (timestamp2tm(timestamp, &tz, &tm, &fsec, &tzn, NULL) == 0)
704 EncodeDateTime(&tm, fsec,
true, tz, tzn, USE_XSD_DATES, buf);
707 (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
708 errmsg(
"timestamp out of range")));
712 elog(ERROR,
"unknown jsonb value datetime type oid %d", typid);
static int postgis_timetz2tm(TimeTzADT *time, struct pg_tm *tm, fsec_t *fsec, int *tzp)
static int postgis_time2tm(TimeADT time, struct pg_tm *tm, fsec_t *fsec)