]> granicus.if.org Git - php/commitdiff
- MFH: Fixing returned offset.
authorDerick Rethans <derick@php.net>
Mon, 7 Apr 2008 17:44:03 +0000 (17:44 +0000)
committerDerick Rethans <derick@php.net>
Mon, 7 Apr 2008 17:44:03 +0000 (17:44 +0000)
- MFH: Algorithm optimization.

ext/date/lib/parse_tz.c
ext/date/lib/unixtime2tm.c

index 9191da6e7cc81bdcd8b8ac3fb9d35b8fc79a5eaf..f7999d111ec09b4572a081490376156d35187d80 100644 (file)
@@ -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);
index b1df1c235657fb0bd613621f0ab9ce861be4366f..3dabea82ba3b68226d1f18e7450ef99b3e9d58b0 100644 (file)
@@ -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;