summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/date.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-03-21 01:31:43 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-03-21 01:31:43 +0000
commit2d0583a166402cbed19ba2b85b6c0b9240cff563 (patch)
tree07a7fd1030484b54fc027c9c66db87c545ab08ac /src/backend/utils/adt/date.c
parent6b0706ac33ab5da815980c642a9cde9a4cd86b6b (diff)
Get rid of a bunch of #ifdef HAVE_INT64_TIMESTAMP conditionals by inventing
a new typedef TimeOffset to represent an intermediate time value. It's either int64 or double as appropriate, and in most usages will be measured in microseconds or seconds the same as Timestamp. We don't call it Timestamp, though, since the value doesn't necessarily represent an absolute time instant. Warren Turkal
Diffstat (limited to 'src/backend/utils/adt/date.c')
-rw-r--r--src/backend/utils/adt/date.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c
index 70f60c94622..5b6b9ebfa97 100644
--- a/src/backend/utils/adt/date.c
+++ b/src/backend/utils/adt/date.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.139 2008/02/17 02:09:28 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.140 2008/03/21 01:31:42 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1838,9 +1838,9 @@ timetztypmodout(PG_FUNCTION_ARGS)
static int
timetz2tm(TimeTzADT *time, struct pg_tm * tm, fsec_t *fsec, int *tzp)
{
-#ifdef HAVE_INT64_TIMESTAMP
- int64 trem = time->time;
+ TimeOffset trem = time->time;
+#ifdef HAVE_INT64_TIMESTAMP
tm->tm_hour = trem / USECS_PER_HOUR;
trem -= tm->tm_hour * USECS_PER_HOUR;
tm->tm_min = trem / USECS_PER_MINUTE;
@@ -1848,8 +1848,6 @@ timetz2tm(TimeTzADT *time, struct pg_tm * tm, fsec_t *fsec, int *tzp)
tm->tm_sec = trem / USECS_PER_SEC;
*fsec = trem - tm->tm_sec * USECS_PER_SEC;
#else
- double trem = time->time;
-
recalc:
TMODULO(trem, tm->tm_hour, (double) SECS_PER_HOUR);
TMODULO(trem, tm->tm_min, (double) SECS_PER_MINUTE);
@@ -1895,17 +1893,14 @@ timetz_scale(PG_FUNCTION_ARGS)
static int
timetz_cmp_internal(TimeTzADT *time1, TimeTzADT *time2)
{
- /* Primary sort is by true (GMT-equivalent) time */
-#ifdef HAVE_INT64_TIMESTAMP
- int64 t1,
+ TimeOffset t1,
t2;
+ /* Primary sort is by true (GMT-equivalent) time */
+#ifdef HAVE_INT64_TIMESTAMP
t1 = time1->time + (time1->zone * USECS_PER_SEC);
t2 = time2->time + (time2->zone * USECS_PER_SEC);
#else
- double t1,
- t2;
-
t1 = time1->time + time1->zone;
t2 = time2->time + time2->zone;
#endif