diff options
| author | Derick Rethans <derick@php.net> | 2008-04-07 17:44:03 +0000 |
|---|---|---|
| committer | Derick Rethans <derick@php.net> | 2008-04-07 17:44:03 +0000 |
| commit | e22155e848e7205185a6a9827b8b26f0142a7445 (patch) | |
| tree | a0e1efe28c6d4011ea096fc91501cd5650d36a50 | |
| parent | e64dc309f96e987b70ceab22a8a743af5de615a7 (diff) | |
| download | php-git-e22155e848e7205185a6a9827b8b26f0142a7445.tar.gz | |
- MFH: Fixing returned offset.
- MFH: Algorithm optimization.
| -rw-r--r-- | ext/date/lib/parse_tz.c | 2 | ||||
| -rw-r--r-- | ext/date/lib/unixtime2tm.c | 16 |
2 files changed, 12 insertions, 6 deletions
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; |
