Prevent timetz2tm() from scribbling on its input in HAVE_INT64_TIMESTAMP case.
This commit is contained in:
parent
1a9b0613c1
commit
478c95a0dc
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.78 2003/01/31 01:08:08 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.79 2003/02/13 17:04:19 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1349,23 +1349,22 @@ timetz_out(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
/* timetz2tm()
|
/* timetz2tm()
|
||||||
* Convert TIME WITH TIME ZONE data type to POSIX time structure.
|
* Convert TIME WITH TIME ZONE data type to POSIX time structure.
|
||||||
* For dates within the system-supported time_t range, convert to the
|
|
||||||
* local time zone. If out of this range, leave as GMT. - tgl 97/05/27
|
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
timetz2tm(TimeTzADT *time, struct tm * tm, fsec_t *fsec, int *tzp)
|
timetz2tm(TimeTzADT *time, struct tm * tm, fsec_t *fsec, int *tzp)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_INT64_TIMESTAMP
|
#ifdef HAVE_INT64_TIMESTAMP
|
||||||
tm->tm_hour = (time->time / INT64CONST(3600000000));
|
int64 trem = time->time;
|
||||||
time->time -= (tm->tm_hour * INT64CONST(3600000000));
|
|
||||||
tm->tm_min = (time->time / INT64CONST(60000000));
|
tm->tm_hour = (trem / INT64CONST(3600000000));
|
||||||
time->time -= (tm->tm_min * INT64CONST(60000000));
|
trem -= (tm->tm_hour * INT64CONST(3600000000));
|
||||||
tm->tm_sec = (time->time / INT64CONST(1000000));
|
tm->tm_min = (trem / INT64CONST(60000000));
|
||||||
*fsec = (time->time - (tm->tm_sec * INT64CONST(1000000)));
|
trem -= (tm->tm_min * INT64CONST(60000000));
|
||||||
#else
|
tm->tm_sec = (trem / INT64CONST(1000000));
|
||||||
double trem;
|
*fsec = (trem - (tm->tm_sec * INT64CONST(1000000)));
|
||||||
|
#else
|
||||||
|
double trem = time->time;
|
||||||
|
|
||||||
trem = time->time;
|
|
||||||
TMODULO(trem, tm->tm_hour, 3600e0);
|
TMODULO(trem, tm->tm_hour, 3600e0);
|
||||||
TMODULO(trem, tm->tm_min, 60e0);
|
TMODULO(trem, tm->tm_min, 60e0);
|
||||||
TMODULO(trem, tm->tm_sec, 1e0);
|
TMODULO(trem, tm->tm_sec, 1e0);
|
||||||
|
Loading…
Reference in New Issue
Block a user