com php-src: Fix backwards transition diffs.: ext/date/lib/interval.c
| From: | Derick Rethans | Date: | Thu, 28 Nov 2013 12:02:36 +0000 |
| Subject: | com php-src: Fix backwards transition diffs.: ext/date/lib/interval.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-74133@lists.php.net to get a copy of this message | ||
Commit: 324e6a5f82d830cf46e0cf35f82c44253b8bd2cf
Author: Derick Rethans <github@derickrethans.nl> Sat, 13 Apr 2013 23:47:23 +0100
Parents: aa26ace21f1457bfcc5faf417d9d453b82944aba
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=324e6a5f82d830cf46e0cf35f82c44253b8bd2cf
Log:
Fix backwards transition diffs..
Changed paths:
M ext/date/lib/interval.c
Diff:
diff --git a/ext/date/lib/interval.c b/ext/date/lib/interval.c
index ded5786..e765a42 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));