postgresql.patch

text/plain

Filename: postgresql.patch
Type: text/plain
Part: 0
Message: Re: Bug #630: date/time storage problem: timestamp parsed

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: unified
File+
src/backend/utils/adt/datetime.c 18 1
Index: src/backend/utils/adt/datetime.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/utils/adt/datetime.c,v
retrieving revision 1.88
diff -u -r1.88 datetime.c
--- src/backend/utils/adt/datetime.c	2002/02/25 16:17:04	1.88
+++ src/backend/utils/adt/datetime.c	2002/04/10 06:12:45
@@ -1439,6 +1439,7 @@
 DetermineLocalTimeZone(struct tm * tm)
 {
 	int			tz;
+	time_t			t;
 
 	if (HasCTZSet)
 		tz = CTimeZone;
@@ -1463,7 +1464,23 @@
 		/* indicate timezone unknown */
 		tmp->tm_isdst = -1;
 
-		mktime(tmp);
+		t = mktime(tmp);
+		if (t == -1)
+		{
+			/* Bump time up by an hour to see if time was an
+			 * invalid time during a daylight savings switch */
+			tmp->tm_hour += 1;
+			t = mktime(tmp);
+
+			/* Assume UTC if mktime() still fails.
+			 *
+			 * If mktime() was successful with the adjusted time,
+			 * adjust the real time object. */
+			if (t == -1)
+				return 0;
+			else
+				tm->tm_hour += 1;
+		}
 
 		tm->tm_isdst = tmp->tm_isdst;