summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerick Rethans <github@derickrethans.nl>2013-04-13 23:47:23 +0100
committerDerick Rethans <github@derickrethans.nl>2013-11-28 12:02:36 +0000
commit324e6a5f82d830cf46e0cf35f82c44253b8bd2cf (patch)
tree9ffb9c5d6e172b0f3230ec4e1d4fc3d801549e4a
parentaa26ace21f1457bfcc5faf417d9d453b82944aba (diff)
downloadphp-git-324e6a5f82d830cf46e0cf35f82c44253b8bd2cf.tar.gz
Fix backwards transition diffs.
-rw-r--r--ext/date/lib/interval.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/ext/date/lib/interval.c b/ext/date/lib/interval.c
index ded57866c2..e765a42e93 100644
--- a/ext/date/lib/interval.c
+++ b/ext/date/lib/interval.c
@@ -65,10 +65,22 @@ timelib_rel_time *timelib_diff(timelib_time *one, timelib_time *two)
rt->h += dst_h_corr;
rt->i += dst_m_corr;
}
+
rt->days = abs(floor((one->sse - two->sse - (dst_h_corr * 3600) - (dst_m_corr * 60)) / 86400));
timelib_do_rel_normalize(rt->invert ? one : two, rt);
+ /* We need to do this after normalisation otherwise we can't get "24H" */
+ if (one_backup.dst == 1 && two_backup.dst == 0 && two->sse >= one->sse + 86400) {
+ if (two->sse < one->sse + 86400 - dst_corr) {
+ rt->d--;
+ rt->h = 24;
+ } else {
+ rt->h += dst_h_corr;
+ rt->i += dst_m_corr;
+ }
+ }
+
/* Restore old TZ info */
memcpy(one, &one_backup, sizeof(one_backup));
memcpy(two, &two_backup, sizeof(two_backup));