diff options
| -rw-r--r-- | ext/date/lib/interval.c | 12 |
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)); |
