June 1, 2018
9:02 p.m.
* zic.c (rpytime): Improve performance when the year is outlandishly small or large. --- zic.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/zic.c b/zic.c index 7c04435..679b3e2 100644 --- a/zic.c +++ b/zic.c @@ -3141,6 +3141,15 @@ rpytime(const struct rule *rp, zic_t wantedy) dayoff = 0; m = TM_JANUARY; y = EPOCH_YEAR; + if (y < wantedy) { + wantedy -= y; + dayoff = (wantedy / YEARSPERREPEAT) * (SECSPERREPEAT / SECSPERDAY); + wantedy %= YEARSPERREPEAT; + wantedy += y; + } else if (wantedy < 0) { + dayoff = (wantedy / YEARSPERREPEAT) * (SECSPERREPEAT / SECSPERDAY); + wantedy %= YEARSPERREPEAT; + } while (wantedy != y) { if (wantedy > y) { i = len_years[isleap(y)]; -- 2.17.0