[PHP-CVS] cvs: php-src /ext/date/lib parse_tz.c timelib_structs.h tm2unixtime.c
by Derick Rethans other posts by this author
Jun 18 2005 12:24PM messages near this date
[PHP-CVS] cvs: php-src /ext/date/tests bug28024.phpt
|
[PHP-CVS] cvs: php-src /ext/date/tests bug32086.phpt bug32555.phpt
derick Sat Jun 18 15:23:59 2005 EDT
Modified files:
/php-src/ext/date/lib parse_tz.c timelib_structs.h tm2unixtime.c
Log:
- Fixed bug in tm2unixtime where the wanted date was in the transition time
between two zones.
#- In this case the wanted date actually didn't exist, and that wasn't
# handled correctly.
http://cvs.php.net/diff.php/php-src/ext/date/lib/parse_tz.c?r1=1.11&r2=1.12&ty=u
Index: php-src/ext/date/lib/parse_tz.c
diff -u php-src/ext/date/lib/parse_tz.c:1.11 php-src/ext/date/lib/parse_tz.c:1.12
--- php-src/ext/date/lib/parse_tz.c:1.11 Sat Jun 18 07:58:18 2005
+++ php-src/ext/date/lib/parse_tz.c Sat Jun 18 15:23:58 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: parse_tz.c,v 1.11 2005/06/18 11:58:18 derick Exp $ */
+/* $Id: parse_tz.c,v 1.12 2005/06/18 19:23:58 derick Exp $ */
#include <timelib_config.h>
@@ -220,7 +220,7 @@
return tmp;
}
-static ttinfo* fetch_timezone_offset(timelib_tzinfo *tz, timelib_sll ts)
+static ttinfo* fetch_timezone_offset(timelib_tzinfo *tz, timelib_sll ts, timelib_sll *trans
ition_time)
{
uint32_t i;
@@ -229,13 +229,16 @@
}
if (ts < tz-> trans[0]) {
+ *transition_time = 0;
return &(tz-> type[tz->trans_idx[tz->timecnt - 1]]);
}
for (i = 0; i < tz-> timecnt; i++) {
if (ts < tz-> trans[i]) {
+ *transition_time = tz-> trans[i - 1];
return &(tz-> type[tz->trans_idx[i - 1]]);
}
}
+ *transition_time = tz-> trans[tz->timecnt - 1];
return &(tz-> type[tz->trans_idx[tz->timecnt - 1]]);
}
@@ -258,7 +261,9 @@
int timelib_timestamp_is_in_dst(timelib_sll ts, timelib_tzinfo *tz)
{
ttinfo *to;
- if ((to = fetch_timezone_offset(tz, ts))) {
+ timelib_sll dummy;
+
+ if ((to = fetch_timezone_offset(tz, ts, &dummy))) {
return to-> isdst;
}
return -1;
@@ -271,14 +276,17 @@
int32_t offset = 0, leap_secs = 0;
char *abbr;
timelib_time_offset *tmp = timelib_time_offset_ctor();
+ timelib_sll transistion_time;
- if ((to = fetch_timezone_offset(tz, ts))) {
+ if ((to = fetch_timezone_offset(tz, ts, &transistion_time))) {
offset = to-> offset;
abbr = &(tz-> timezone_abbr[to->abbr_idx]);
tmp-> is_dst = to->isdst;
+ tmp-> transistion_time = transistion_time;
} else {
abbr = tz-> timezone_abbr;
tmp-> is_dst = 0;
+ tmp-> transistion_time = 0;
}
if ((tl = fetch_leaptime_offset(tz, ts))) {
http://cvs.php.net/diff.php/php-src/ext/date/lib/timelib_structs.h?r1=1.8&r2=1.9&ty=u
Index: php-src/ext/date/lib/timelib_structs.h
diff -u php-src/ext/date/lib/timelib_structs.h:1.8 php-src/ext/date/lib/timelib_structs.h:1.
9
--- php-src/ext/date/lib/timelib_structs.h:1.8 Fri Jun 17 10:54:00 2005
+++ php-src/ext/date/lib/timelib_structs.h Sat Jun 18 15:23:58 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: timelib_structs.h,v 1.8 2005/06/17 14:54:00 derick Exp $ */
+/* $Id: timelib_structs.h,v 1.9 2005/06/18 19:23:58 derick Exp $ */
#ifndef __TIMELIB_STRUCTS_H__
#define __TIMELIB_STRUCTS_H__
@@ -119,6 +119,7 @@
unsigned int leap_secs;
unsigned int is_dst;
char *abbr;
+ timelib_sll transistion_time;
} timelib_time_offset;
typedef struct timelib_time {
http://cvs.php.net/diff.php/php-src/ext/date/lib/tm2unixtime.c?r1=1.9&r2=1.10&ty=u
Index: php-src/ext/date/lib/tm2unixtime.c
diff -u php-src/ext/date/lib/tm2unixtime.c:1.9 php-src/ext/date/lib/tm2unixtime.c:1.10
--- php-src/ext/date/lib/tm2unixtime.c:1.9 Fri Jun 17 10:54:00 2005
+++ php-src/ext/date/lib/tm2unixtime.c Sat Jun 18 15:23:58 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: tm2unixtime.c,v 1.9 2005/06/17 14:54:00 derick Exp $ */
+/* $Id: tm2unixtime.c,v 1.10 2005/06/18 19:23:58 derick Exp $ */
#include <timelib_config.h>
#include "timelib.h"
@@ -209,14 +209,21 @@
/* No timezone in struct, fallback to reference if possible */
if (tzi) {
timelib_time_offset *before, *after;
- timelib_sll tmp;
+ timelib_sll tmp;
+ int in_transistion;
tz-> is_localtime = 1;
before = timelib_get_time_zone_info(tz-> sse, tzi);
after = timelib_get_time_zone_info(tz-> sse - before->offset, tzi);
timelib_set_timezone(tz, tzi);
- if (before-> is_dst != after->is_dst) {
- tmp = -tz-> z + (before->offset - after->offset);
+
+ in_transistion = (
+ ((tz-> sse - after->offset) >= (after->transistion_time + (before->offset - after->offs
et))) &&
+ ((tz-> sse - after->offset) < after->transistion_time)
+ );
+
+ if ((before-> offset != after->offset) && !in_transistion) {
+ tmp = -after-> offset;
} else {
tmp = -tz-> z;
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
|