diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2012-03-14 23:03:34 +0200 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2012-03-14 23:03:34 +0200 |
commit | ad4fb0d0d2f33ec0165f2a9a50a6d8cbcef4ab82 (patch) | |
tree | 46e07054f4e064ef6f496ad5565c9d6502205de7 /src/backend/utils/adt/timestamp.c | |
parent | 942b63193c722a58ed24b3305308836b47b3f028 (diff) | |
download | postgresql-ad4fb0d0d2f33ec0165f2a9a50a6d8cbcef4ab82.tar.gz postgresql-ad4fb0d0d2f33ec0165f2a9a50a6d8cbcef4ab82.zip |
Improve EncodeDateTime and EncodeTimeOnly APIs
Use an explicit argument to tell whether to include the time zone in
the output, rather than using some undocumented pointer magic.
Diffstat (limited to 'src/backend/utils/adt/timestamp.c')
-rw-r--r-- | src/backend/utils/adt/timestamp.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index db434dcb3cc..edcce5f31ef 100644 --- a/src/backend/utils/adt/timestamp.c +++ b/src/backend/utils/adt/timestamp.c @@ -215,13 +215,12 @@ timestamp_out(PG_FUNCTION_ARGS) struct pg_tm tt, *tm = &tt; fsec_t fsec; - char *tzn = NULL; char buf[MAXDATELEN + 1]; if (TIMESTAMP_NOT_FINITE(timestamp)) EncodeSpecialTimestamp(timestamp, buf); else if (timestamp2tm(timestamp, NULL, tm, &fsec, NULL, NULL) == 0) - EncodeDateTime(tm, fsec, NULL, &tzn, DateStyle, buf); + EncodeDateTime(tm, fsec, false, 0, NULL, DateStyle, buf); else ereport(ERROR, (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE), @@ -501,7 +500,7 @@ timestamptz_out(PG_FUNCTION_ARGS) if (TIMESTAMP_NOT_FINITE(dt)) EncodeSpecialTimestamp(dt, buf); else if (timestamp2tm(dt, &tz, tm, &fsec, &tzn, NULL) == 0) - EncodeDateTime(tm, fsec, &tz, &tzn, DateStyle, buf); + EncodeDateTime(tm, fsec, true, tz, tzn, DateStyle, buf); else ereport(ERROR, (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE), @@ -1422,7 +1421,7 @@ timestamptz_to_str(TimestampTz t) if (TIMESTAMP_NOT_FINITE(t)) EncodeSpecialTimestamp(t, buf); else if (timestamp2tm(t, &tz, tm, &fsec, &tzn, NULL) == 0) - EncodeDateTime(tm, fsec, &tz, &tzn, USE_ISO_DATES, buf); + EncodeDateTime(tm, fsec, true, tz, tzn, USE_ISO_DATES, buf); else strlcpy(buf, "(timestamp out of range)", sizeof(buf)); |