From: Derick Rethans Date: Mon, 7 Apr 2008 17:44:03 +0000 (+0000) Subject: - MFH: Fixing returned offset. X-Git-Tag: BEFORE_NEW_PARAMETER_PARSE~423 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e22155e848e7205185a6a9827b8b26f0142a7445;p=php - MFH: Fixing returned offset. - MFH: Algorithm optimization. --- diff --git a/ext/date/lib/parse_tz.c b/ext/date/lib/parse_tz.c index 9191da6e7c..f7999d111e 100644 --- a/ext/date/lib/parse_tz.c +++ b/ext/date/lib/parse_tz.c @@ -391,7 +391,7 @@ timelib_sll timelib_get_current_offset(timelib_time *t) switch (t->zone_type) { case TIMELIB_ZONETYPE_ABBR: case TIMELIB_ZONETYPE_OFFSET: - return t->z * 60; + return (t->z + t->dst) * -60; case TIMELIB_ZONETYPE_ID: gmt_offset = timelib_get_time_zone_info(t->sse, t->tz_info); diff --git a/ext/date/lib/unixtime2tm.c b/ext/date/lib/unixtime2tm.c index b1df1c2356..3dabea82ba 100644 --- a/ext/date/lib/unixtime2tm.c +++ b/ext/date/lib/unixtime2tm.c @@ -76,12 +76,18 @@ void timelib_unixtime2gmt(timelib_time* tm, timelib_sll ts) */ while (tmp_days <= 0) { - cur_year--; - DEBUG(printf("tmp_days=%lld, year=%lld\n", tmp_days, cur_year);); - if (timelib_is_leap(cur_year)) { - tmp_days += DAYS_PER_LYEAR; + if (tmp_days < -1460970) { + cur_year -= 4000; + DEBUG(printf("tmp_days=%lld, year=%lld\n", tmp_days, cur_year);); + tmp_days += 1460970; } else { - tmp_days += DAYS_PER_YEAR; + cur_year--; + DEBUG(printf("tmp_days=%lld, year=%lld\n", tmp_days, cur_year);); + if (timelib_is_leap(cur_year)) { + tmp_days += DAYS_PER_LYEAR; + } else { + tmp_days += DAYS_PER_YEAR; + } } } remainder += SECS_PER_DAY;