mirror of
				https://github.com/postgres/postgres.git
				synced 2025-10-31 00:03:57 -04:00 
			
		
		
		
	Display only 9 not 10 digits of precision for timestamp values when
using non-integer timestamps. This prevents the display of rounding errors for common values like days < 32.
This commit is contained in:
		
							parent
							
								
									b3195dae49
								
							
						
					
					
						commit
						4c862b18f9
					
				| @ -8,7 +8,7 @@ | |||||||
|  * |  * | ||||||
|  * |  * | ||||||
|  * IDENTIFICATION |  * IDENTIFICATION | ||||||
|  *	  $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.145 2005/05/26 02:04:13 neilc Exp $ |  *	  $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.146 2005/05/26 03:48:25 momjian Exp $ | ||||||
|  * |  * | ||||||
|  *------------------------------------------------------------------------- |  *------------------------------------------------------------------------- | ||||||
|  */ |  */ | ||||||
| @ -3461,7 +3461,7 @@ EncodeTimeOnly(struct pg_tm * tm, fsec_t fsec, int *tzp, int style, char *str) | |||||||
| #ifdef HAVE_INT64_TIMESTAMP | #ifdef HAVE_INT64_TIMESTAMP | ||||||
| 		sprintf(str + strlen(str), ":%02d.%06d", tm->tm_sec, fsec); | 		sprintf(str + strlen(str), ":%02d.%06d", tm->tm_sec, fsec); | ||||||
| #else | #else | ||||||
| 		sprintf(str + strlen(str), ":%013.10f", tm->tm_sec + fsec); | 		sprintf(str + strlen(str), ":%012.9f", tm->tm_sec + fsec); | ||||||
| #endif | #endif | ||||||
| 		/* chop off trailing pairs of zeros... */ | 		/* chop off trailing pairs of zeros... */ | ||||||
| 		while (strcmp((str + strlen(str) - 2), "00") == 0 && | 		while (strcmp((str + strlen(str) - 2), "00") == 0 && | ||||||
| @ -3804,7 +3804,7 @@ EncodeInterval(struct pg_tm * tm, fsec_t fsec, int style, char *str) | |||||||
| 					sprintf(cp, ".%06d", Abs(fsec)); | 					sprintf(cp, ".%06d", Abs(fsec)); | ||||||
| #else | #else | ||||||
| 					fsec += tm->tm_sec; | 					fsec += tm->tm_sec; | ||||||
| 					sprintf(cp, ":%013.10f", fabs(fsec)); | 					sprintf(cp, ":%012.9f", fabs(fsec)); | ||||||
| #endif | #endif | ||||||
| 					TrimTrailingZeros(cp); | 					TrimTrailingZeros(cp); | ||||||
| 					cp += strlen(cp); | 					cp += strlen(cp); | ||||||
|  | |||||||
| @ -511,7 +511,7 @@ EncodeInterval(struct tm * tm, fsec_t fsec, int style, char *str) | |||||||
| 					sprintf(cp, ".%06d", (fsec >= 0) ? fsec : -(fsec)); | 					sprintf(cp, ".%06d", (fsec >= 0) ? fsec : -(fsec)); | ||||||
| #else | #else | ||||||
| 					fsec += tm->tm_sec; | 					fsec += tm->tm_sec; | ||||||
| 					sprintf(cp, ":%013.10f", fabs(fsec)); | 					sprintf(cp, ":%012.9f", fabs(fsec)); | ||||||
| #endif | #endif | ||||||
| 					TrimTrailingZeros(cp); | 					TrimTrailingZeros(cp); | ||||||
| 					cp += strlen(cp); | 					cp += strlen(cp); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user