php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch handle-forward-dst-changeover-in-timelib for Date/time related Bug #75167

Patch version 2017-09-08 05:36 UTC

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

Developer: knutoh@gmail.com

From 2c3127dc24b16a2a8ed4f11dd146805b3bad1eb6 Mon Sep 17 00:00:00 2001
From: Knut Helland <knutoh@gmail.com>
Date: Fri, 8 Sep 2017 07:34:35 +0200
Subject: [PATCH] Fix bug #75167 in timelib

---
 ext/date/lib/interval.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/ext/date/lib/interval.c b/ext/date/lib/interval.c
index e9fa274..beedb9f 100644
--- a/ext/date/lib/interval.c
+++ b/ext/date/lib/interval.c
@@ -120,8 +120,8 @@ timelib_time *timelib_add(timelib_time *old_time, timelib_rel_time *interval)
 	timelib_update_ts(t, NULL);
 
 //	printf("%lld %lld %d\n", old_time->dst, t->dst, (t->sse - old_time->sse));
-	/* Adjust for backwards DST changeover */
-	if (old_time->dst == 1 && t->dst == 0 && !interval->y && !interval->m && !interval->d) {
+	/* Adjust for DST changeover */
+	if (old_time->dst != t->dst && !interval->y && !interval->m && !interval->d) {
 		t->sse -= old_time->z;
 		t->sse += t->z;
 	}
@@ -154,13 +154,8 @@ timelib_time *timelib_sub(timelib_time *old_time, timelib_rel_time *interval)
 
 	timelib_update_ts(t, NULL);
 
-	/* Adjust for backwards DST changeover */
-	if (old_time->dst == 1 && t->dst == 0 && !interval->y && !interval->m && !interval->d) {
-		t->sse -= old_time->z;
-		t->sse += t->z;
-	}
-	/* Adjust for forwards DST changeover */
-	if (old_time->dst == 0 && t->dst == 1 && !interval->y && !interval->m && !interval->d ) {
+	/* Adjust for DST changeover */
+	if (old_time->dst != t->dst && !interval->y && !interval->m && !interval->d) {
 		t->sse -= old_time->z;
 		t->sse += t->z;
 	}
-- 
2.10.1

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Jul 17 08:01:26 2019 UTC