1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-25 01:02:05 +03:00

Make EXTRACT(TIMEZONE) and SET/SHOW TIMEZONE follow the SQL convention

for the sign of timezone offsets, ie, positive is east from UTC.  These
were previously out of step with other operations that accept or show
timezones, such as I/O of timestamptz values.
This commit is contained in:
Tom Lane
2003-07-17 00:55:37 +00:00
parent 93236b58e0
commit 764f72dc82
10 changed files with 74 additions and 41 deletions

View File

@ -183,12 +183,23 @@ typedef struct
} datetkn;
/* TMODULO()
/* FMODULO()
* Macro to replace modf(), which is broken on some platforms.
* t = input and remainder
* q = integer part
* u = divisor
*/
#define FMODULO(t,q,u) \
do { \
q = ((t < 0) ? ceil(t / u): floor(t / u)); \
if (q != 0) t -= rint(q * u); \
} while(0)
/* TMODULO()
* Like FMODULO(), but work on the timestamp datatype (either int64 or float8).
* We assume that int64 follows the C99 semantics for division (negative
* quotients truncate towards zero).
*/
#ifdef HAVE_INT64_TIMESTAMP
#define TMODULO(t,q,u) \
do { \
@ -198,7 +209,7 @@ do { \
#else
#define TMODULO(t,q,u) \
do { \
q = ((t < 0)? ceil(t / u): floor(t / u)); \
q = ((t < 0) ? ceil(t / u): floor(t / u)); \
if (q != 0) t -= rint(q * u); \
} while(0)
#endif