88 *
99 *
1010 * IDENTIFICATION
11- * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.139 2005/07/22 03:46:34 momjian Exp $
11+ * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.140 2005/07/22 15:15:38 momjian Exp $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
@@ -3944,11 +3944,13 @@ timestamp_zone(PG_FUNCTION_ARGS)
39443944 PG_RETURN_TIMESTAMPTZ (timestamp );
39453945
39463946 /* Find the specified timezone? */
3947- len = (VARSIZE (zone )- VARHDRSZ > TZ_STRLEN_MAX )?TZ_STRLEN_MAX :(VARSIZE (zone )- VARHDRSZ );
3948- memcpy (tzname ,VARDATA (zone ),len );
3947+ len = (VARSIZE (zone ) - VARHDRSZ > TZ_STRLEN_MAX ) ?
3948+ TZ_STRLEN_MAX : VARSIZE (zone ) - VARHDRSZ ;
3949+ memcpy (tzname , VARDATA (zone ), len );
39493950 tzname [len ] = 0 ;
39503951 tzp = pg_tzset (tzname );
3951- if (!tzp ) {
3952+ if (!tzp )
3953+ {
39523954 ereport (ERROR ,
39533955 (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
39543956 errmsg ("time zone \"%s\" not recognised" ,
@@ -3958,15 +3960,16 @@ timestamp_zone(PG_FUNCTION_ARGS)
39583960
39593961 /* Apply the timezone change */
39603962 if (timestamp2tm (timestamp , & tz , & tm , & fsec , NULL , tzp ) != 0 ||
3961- tm2timestamp (& tm , fsec , NULL , & result ) != 0 ) {
3963+ tm2timestamp (& tm , fsec , NULL , & result ) != 0 )
3964+ {
39623965 ereport (ERROR ,
39633966 (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
39643967 errmsg ("could not convert to time zone \"%s\"" ,
39653968 tzname )));
39663969 PG_RETURN_NULL ();
39673970 }
39683971 PG_RETURN_TIMESTAMPTZ (timestamp2timestamptz (result ));
3969- } /* timestamp_zone() */
3972+ }
39703973
39713974/* timestamp_izone()
39723975 * Encode timestamp type with specified time interval as time zone.
@@ -4022,7 +4025,6 @@ timestamp2timestamptz(Timestamp timestamp)
40224025
40234026 if (TIMESTAMP_NOT_FINITE (timestamp ))
40244027 result = timestamp ;
4025-
40264028 else
40274029 {
40284030 if (timestamp2tm (timestamp , NULL , tm , & fsec , NULL , NULL ) != 0 )
@@ -4057,7 +4059,6 @@ timestamptz_timestamp(PG_FUNCTION_ARGS)
40574059
40584060 if (TIMESTAMP_NOT_FINITE (timestamp ))
40594061 result = timestamp ;
4060-
40614062 else
40624063 {
40634064 if (timestamp2tm (timestamp , & tz , tm , & fsec , & tzn , NULL ) != 0 )
@@ -4082,7 +4083,6 @@ timestamptz_zone(PG_FUNCTION_ARGS)
40824083 text * zone = PG_GETARG_TEXT_P (0 );
40834084 TimestampTz timestamp = PG_GETARG_TIMESTAMPTZ (1 );
40844085 Timestamp result ;
4085-
40864086 int tz ;
40874087 pg_tz * tzp ;
40884088 char tzname [TZ_STRLEN_MAX ];
@@ -4094,12 +4094,14 @@ timestamptz_zone(PG_FUNCTION_ARGS)
40944094 PG_RETURN_NULL ();
40954095
40964096 /* Find the specified zone */
4097- len = (VARSIZE (zone )- VARHDRSZ > TZ_STRLEN_MAX )?TZ_STRLEN_MAX :(VARSIZE (zone )- VARHDRSZ );
4098- memcpy (tzname ,VARDATA (zone ),len );
4097+ len = (VARSIZE (zone ) - VARHDRSZ > TZ_STRLEN_MAX ) ?
4098+ TZ_STRLEN_MAX : VARSIZE (zone ) - VARHDRSZ ;
4099+ memcpy (tzname , VARDATA (zone ), len );
40994100 tzname [len ] = 0 ;
41004101 tzp = pg_tzset (tzname );
41014102
4102- if (!tzp ) {
4103+ if (!tzp )
4104+ {
41034105 ereport (ERROR ,
41044106 (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
41054107 errmsg ("time zone \"%s\" not recognized" , tzname )));
@@ -4108,15 +4110,16 @@ timestamptz_zone(PG_FUNCTION_ARGS)
41084110 }
41094111
41104112 if (timestamp2tm (timestamp , & tz , & tm , & fsec , NULL , tzp ) != 0 ||
4111- tm2timestamp (& tm , fsec , NULL , & result )) {
4113+ tm2timestamp (& tm , fsec , NULL , & result ))
4114+ {
41124115 ereport (ERROR ,
41134116 (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
41144117 errmsg ("could not to convert to time zone \"%s\"" , tzname )));
41154118 PG_RETURN_NULL ();
41164119 }
41174120
41184121 PG_RETURN_TIMESTAMP (result );
4119- } /* timestamptz_zone() */
4122+ }
41204123
41214124/* timestamptz_izone()
41224125 * Encode timestamp with time zone type with specified time interval as time zone.
@@ -4149,4 +4152,4 @@ timestamptz_izone(PG_FUNCTION_ARGS)
41494152 result = dt2local (timestamp , tz );
41504153
41514154 PG_RETURN_TIMESTAMP (result );
4152- } /* timestamptz_izone() */
4155+ }
0 commit comments