php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #52142
Patch bug52142-fix_interval.c.patch revision 2010-08-15 21:18 UTC by strager dot nds at gmail dot com
Patch bug52142.phpt revision 2010-08-15 21:18 UTC by strager dot nds at gmail dot com

Patch bug52142-fix_interval.c.patch for Date/time related Bug #52142

Patch version 2010-08-15 21:18 UTC

Return to Bug #52142 | Download this patch
Patch Revisions:

Developer: strager.nds@gmail.com

--- ext/date/lib/interval.c.old	2010-08-15 17:08:55.535603832 -0400
+++ ext/date/lib/interval.c	2010-08-15 17:07:33.575603532 -0400
@@ -26,6 +26,8 @@
 	timelib_time *swp;
 	timelib_sll dst_h_corr = 0, dst_m_corr = 0;
 
+    timelib_time one_copy, two_copy;
+
 	rt = timelib_rel_time_ctor();
 	rt->invert = 0;
 	if (one->sse > two->sse) {
@@ -45,21 +47,21 @@
 		dst_m_corr = ((two->z - one->z) % 3600) / 60;
 	}
 
-    timelib_apply_localtime(one, 0);
-    timelib_apply_localtime(two, 0);
+    one_copy = *one;
+    two_copy = *two;
 
-	rt->y = two->y - one->y;
-	rt->m = two->m - one->m;
-	rt->d = two->d - one->d;
-	rt->h = two->h - one->h + dst_h_corr;
-	rt->i = two->i - one->i + dst_m_corr;
-	rt->s = two->s - one->s;
-	rt->days = abs(floor((one->sse - two->sse - (dst_h_corr * 3600) - (dst_m_corr * 60)) / 86400));
+    timelib_apply_localtime(&one_copy, 0);
+    timelib_apply_localtime(&two_copy, 0);
 
-	timelib_do_rel_normalize(rt->invert ? one : two, rt);
+	rt->y = two_copy.y - one_copy.y;
+	rt->m = two_copy.m - one_copy.m;
+	rt->d = two_copy.d - one_copy.d;
+	rt->h = two_copy.h - one_copy.h + dst_h_corr;
+	rt->i = two_copy.i - one_copy.i + dst_m_corr;
+	rt->s = two_copy.s - one_copy.s;
+	rt->days = abs(floor((one_copy.sse - two_copy.sse - (dst_h_corr * 3600) - (dst_m_corr * 60)) / 86400));
 
-    timelib_apply_localtime(one, 1);
-    timelib_apply_localtime(two, 1);
+	timelib_do_rel_normalize(rt->invert ? &one_copy : &two_copy, rt);
 
 	return rt;
 }
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 05:01:31 2024 UTC