88 *
99 *
1010 * IDENTIFICATION
11- * $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.114 2005/07/2103:56:13 momjian Exp $
11+ * $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.115 2005/07/2104:41:43 momjian Exp $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
@@ -304,8 +304,7 @@ date2timestamptz(DateADT dateVal)
304304tz = DetermineLocalTimeZone (tm );
305305
306306#ifdef HAVE_INT64_TIMESTAMP
307- result = (dateVal * USECS_PER_DAY )
308- + (tz * USECS_PER_SEC );
307+ result = dateVal * USECS_PER_DAY + tz * USECS_PER_SEC ;
309308#else
310309result = dateVal * (double )SECS_PER_DAY + tz ;
311310#endif
@@ -725,7 +724,7 @@ timestamp_date(PG_FUNCTION_ARGS)
725724if (TIMESTAMP_NOT_FINITE (timestamp ))
726725PG_RETURN_NULL ();
727726
728- if (timestamp2tm (timestamp ,NULL ,tm ,& fsec ,NULL ,NULL )!= 0 )
727+ if (timestamp2tm (timestamp ,NULL ,tm ,& fsec ,NULL ,NULL )!= 0 )
729728ereport (ERROR ,
730729(errcode (ERRCODE_DATETIME_VALUE_OUT_OF_RANGE ),
731730errmsg ("timestamp out of range" )));
@@ -768,7 +767,7 @@ timestamptz_date(PG_FUNCTION_ARGS)
768767if (TIMESTAMP_NOT_FINITE (timestamp ))
769768PG_RETURN_NULL ();
770769
771- if (timestamp2tm (timestamp ,& tz ,tm ,& fsec ,& tzn ,NULL )!= 0 )
770+ if (timestamp2tm (timestamp ,& tz ,tm ,& fsec ,& tzn ,NULL )!= 0 )
772771ereport (ERROR ,
773772(errcode (ERRCODE_DATETIME_VALUE_OUT_OF_RANGE ),
774773errmsg ("timestamp out of range" )));
@@ -829,7 +828,7 @@ date_text(PG_FUNCTION_ARGS)
829828
830829str = DatumGetCString (DirectFunctionCall1 (date_out ,date ));
831830
832- len = ( strlen (str )+ VARHDRSZ ) ;
831+ len = strlen (str )+ VARHDRSZ ;
833832
834833result = palloc (len );
835834
@@ -1337,7 +1336,7 @@ timestamp_time(PG_FUNCTION_ARGS)
13371336if (TIMESTAMP_NOT_FINITE (timestamp ))
13381337PG_RETURN_NULL ();
13391338
1340- if (timestamp2tm (timestamp ,NULL ,tm ,& fsec ,NULL ,NULL )!= 0 )
1339+ if (timestamp2tm (timestamp ,NULL ,tm ,& fsec ,NULL ,NULL )!= 0 )
13411340ereport (ERROR ,
13421341(errcode (ERRCODE_DATETIME_VALUE_OUT_OF_RANGE ),
13431342errmsg ("timestamp out of range" )));
@@ -1374,7 +1373,7 @@ timestamptz_time(PG_FUNCTION_ARGS)
13741373if (TIMESTAMP_NOT_FINITE (timestamp ))
13751374PG_RETURN_NULL ();
13761375
1377- if (timestamp2tm (timestamp ,& tz ,tm ,& fsec ,& tzn ,NULL )!= 0 )
1376+ if (timestamp2tm (timestamp ,& tz ,tm ,& fsec ,& tzn ,NULL )!= 0 )
13781377ereport (ERROR ,
13791378(errcode (ERRCODE_DATETIME_VALUE_OUT_OF_RANGE ),
13801379errmsg ("timestamp out of range" )));
@@ -1496,14 +1495,14 @@ time_pl_interval(PG_FUNCTION_ARGS)
14961495TimeADT result ;
14971496
14981497#ifdef HAVE_INT64_TIMESTAMP
1499- result = ( time + span -> time ) ;
1500- result -= ( result /USECS_PER_DAY * USECS_PER_DAY ) ;
1498+ result = time + span -> time ;
1499+ result -= result /USECS_PER_DAY * USECS_PER_DAY ;
15011500if (result < INT64CONST (0 ))
15021501result += USECS_PER_DAY ;
15031502#else
15041503TimeADT time1 ;
15051504
1506- result = ( time + span -> time ) ;
1505+ result = time + span -> time ;
15071506TMODULO (result ,time1 , (double )SECS_PER_DAY );
15081507if (result < 0 )
15091508result += SECS_PER_DAY ;
@@ -1523,14 +1522,14 @@ time_mi_interval(PG_FUNCTION_ARGS)
15231522TimeADT result ;
15241523
15251524#ifdef HAVE_INT64_TIMESTAMP
1526- result = ( time - span -> time ) ;
1527- result -= ( result /USECS_PER_DAY * USECS_PER_DAY ) ;
1525+ result = time - span -> time ;
1526+ result -= result /USECS_PER_DAY * USECS_PER_DAY ;
15281527if (result < INT64CONST (0 ))
15291528result += USECS_PER_DAY ;
15301529#else
15311530TimeADT time1 ;
15321531
1533- result = ( time - span -> time ) ;
1532+ result = time - span -> time ;
15341533TMODULO (result ,time1 , (double )SECS_PER_DAY );
15351534if (result < 0 )
15361535result += SECS_PER_DAY ;
@@ -1554,7 +1553,7 @@ time_text(PG_FUNCTION_ARGS)
15541553
15551554str = DatumGetCString (DirectFunctionCall1 (time_out ,time ));
15561555
1557- len = ( strlen (str )+ VARHDRSZ ) ;
1556+ len = strlen (str )+ VARHDRSZ ;
15581557
15591558result = palloc (len );
15601559
@@ -1685,7 +1684,7 @@ time_part(PG_FUNCTION_ARGS)
16851684else if (type == RESERV && val == DTK_EPOCH )
16861685{
16871686#ifdef HAVE_INT64_TIMESTAMP
1688- result = ( time /1000000.0 ) ;
1687+ result = time /1000000.0 ;
16891688#else
16901689result = time ;
16911690#endif
@@ -2036,12 +2035,12 @@ timetz_pl_interval(PG_FUNCTION_ARGS)
20362035result = (TimeTzADT * )palloc (sizeof (TimeTzADT ));
20372036
20382037#ifdef HAVE_INT64_TIMESTAMP
2039- result -> time = ( time -> time + span -> time ) ;
2040- result -> time -= ( result -> time /USECS_PER_DAY * USECS_PER_DAY ) ;
2038+ result -> time = time -> time + span -> time ;
2039+ result -> time -= result -> time /USECS_PER_DAY * USECS_PER_DAY ;
20412040if (result -> time < INT64CONST (0 ))
20422041result -> time += USECS_PER_DAY ;
20432042#else
2044- result -> time = ( time -> time + span -> time ) ;
2043+ result -> time = time -> time + span -> time ;
20452044TMODULO (result -> time ,time1 .time , (double )SECS_PER_DAY );
20462045if (result -> time < 0 )
20472046result -> time += SECS_PER_DAY ;
@@ -2069,12 +2068,12 @@ timetz_mi_interval(PG_FUNCTION_ARGS)
20692068result = (TimeTzADT * )palloc (sizeof (TimeTzADT ));
20702069
20712070#ifdef HAVE_INT64_TIMESTAMP
2072- result -> time = ( time -> time - span -> time ) ;
2073- result -> time -= ( result -> time /USECS_PER_DAY * USECS_PER_DAY ) ;
2071+ result -> time = time -> time - span -> time ;
2072+ result -> time -= result -> time /USECS_PER_DAY * USECS_PER_DAY ;
20742073if (result -> time < INT64CONST (0 ))
20752074result -> time += USECS_PER_DAY ;
20762075#else
2077- result -> time = ( time -> time - span -> time ) ;
2076+ result -> time = time -> time - span -> time ;
20782077TMODULO (result -> time ,time1 .time , (double )SECS_PER_DAY );
20792078if (result -> time < 0 )
20802079result -> time += SECS_PER_DAY ;
@@ -2265,7 +2264,7 @@ timestamptz_timetz(PG_FUNCTION_ARGS)
22652264if (TIMESTAMP_NOT_FINITE (timestamp ))
22662265PG_RETURN_NULL ();
22672266
2268- if (timestamp2tm (timestamp ,& tz ,tm ,& fsec ,& tzn ,NULL )!= 0 )
2267+ if (timestamp2tm (timestamp ,& tz ,tm ,& fsec ,& tzn ,NULL )!= 0 )
22692268ereport (ERROR ,
22702269(errcode (ERRCODE_DATETIME_VALUE_OUT_OF_RANGE ),
22712270errmsg ("timestamp out of range" )));
@@ -2315,7 +2314,7 @@ timetz_text(PG_FUNCTION_ARGS)
23152314
23162315str = DatumGetCString (DirectFunctionCall1 (timetz_out ,timetz ));
23172316
2318- len = ( strlen (str )+ VARHDRSZ ) ;
2317+ len = strlen (str )+ VARHDRSZ ;
23192318
23202319result = palloc (len );
23212320
@@ -2497,7 +2496,8 @@ timetz_zone(PG_FUNCTION_ARGS)
24972496pg_time_t now ;
24982497
24992498/* Find the specified timezone */
2500- len = (VARSIZE (zone )- VARHDRSZ > TZ_STRLEN_MAX )?TZ_STRLEN_MAX :(VARSIZE (zone )- VARHDRSZ );
2499+ len = (VARSIZE (zone )- VARHDRSZ > TZ_STRLEN_MAX ) ?
2500+ TZ_STRLEN_MAX :VARSIZE (zone )- VARHDRSZ ;
25012501memcpy (tzname ,VARDATA (zone ),len );
25022502tzname [len ]= 0 ;
25032503tzp = pg_tzset (tzname );