diff options
author | Derick Rethans <derick@php.net> | 2005-12-19 13:00:37 +0000 |
---|---|---|
committer | Derick Rethans <derick@php.net> | 2005-12-19 13:00:37 +0000 |
commit | 7b581f6d19957871df502c8563a4eae8e54c15ca (patch) | |
tree | 460c86b1d8eac8aa0de09db74a80855c6c09c2bd /ext/date/lib/unixtime2tm.c | |
parent | 32220d2e7e60d68ecdf245fb69b4f9208ec37fe0 (diff) | |
download | php-git-7b581f6d19957871df502c8563a4eae8e54c15ca.tar.gz |
- MFH: Merged new timelib, which is a bit more cleverer
- MFH: Support "UTC" in strtotime() properly.
- MFH: Added astro code, which is going to form the base for the new sunfuncs.
Diffstat (limited to 'ext/date/lib/unixtime2tm.c')
-rw-r--r-- | ext/date/lib/unixtime2tm.c | 51 |
1 files changed, 34 insertions, 17 deletions
diff --git a/ext/date/lib/unixtime2tm.c b/ext/date/lib/unixtime2tm.c index 984187d324..0187abbcfb 100644 --- a/ext/date/lib/unixtime2tm.c +++ b/ext/date/lib/unixtime2tm.c @@ -121,7 +121,6 @@ void timelib_unixtime2gmt(timelib_time* tm, timelib_sll ts) tm->sse_uptodate = 1; tm->tim_uptodate = 1; tm->is_localtime = 0; - tm->have_zone = 0; } void timelib_update_from_sse(timelib_time *tm) @@ -138,8 +137,6 @@ void timelib_update_from_sse(timelib_time *tm) timelib_unixtime2gmt(tm, tm->sse - (tm->z * 60)); - tm->is_localtime = 1; - tm->have_zone = 1; tm->z = z; tm->dst = dst; goto cleanup; @@ -165,25 +162,45 @@ cleanup: tm->have_zone = 1; } -void timelib_unixtime2local(timelib_time *tm, timelib_sll ts, timelib_tzinfo* tz) +void timelib_unixtime2local(timelib_time *tm, timelib_sll ts) { timelib_time_offset *gmt_offset; + timelib_tzinfo *tz = tm->tz_info; - gmt_offset = timelib_get_time_zone_info(ts, tz); - timelib_unixtime2gmt(tm, ts + gmt_offset->offset); + tm->is_localtime = 1; + tm->have_zone = 1; - /* we need to reset the sse here as unixtime2gmt modifies it */ - tm->sse = ts; - tm->dst = gmt_offset->is_dst; - tm->z = gmt_offset->offset; - tm->tz_info = tz; + switch (tm->zone_type) { + case TIMELIB_ZONETYPE_ABBR: + case TIMELIB_ZONETYPE_OFFSET: { + int z = tm->z; + signed int dst = tm->dst; + + timelib_unixtime2gmt(tm, ts - (tm->z * 60)); - timelib_time_tz_abbr_update(tm, gmt_offset->abbr); - timelib_time_offset_dtor(gmt_offset); + tm->z = z; + tm->dst = dst; + break; + } - tm->is_localtime = 1; - tm->have_zone = 1; - tm->zone_type = TIMELIB_ZONETYPE_ID; + case TIMELIB_ZONETYPE_ID: + gmt_offset = timelib_get_time_zone_info(ts, tz); + timelib_unixtime2gmt(tm, ts + gmt_offset->offset); + + /* we need to reset the sse here as unixtime2gmt modifies it */ + tm->sse = ts; + tm->dst = gmt_offset->is_dst; + tm->z = gmt_offset->offset; + tm->tz_info = tz; + + timelib_time_tz_abbr_update(tm, gmt_offset->abbr); + timelib_time_offset_dtor(gmt_offset); + break; + + default: + tm->is_localtime = 0; + tm->have_zone = 0; + } } void timelib_set_timezone(timelib_time *t, timelib_tzinfo *tz) @@ -225,7 +242,7 @@ int timelib_apply_localtime(timelib_time *t, unsigned int localtime) return -1; } - timelib_unixtime2local(t, t->sse, t->tz_info); + timelib_unixtime2local(t, t->sse); } else { /* Converting from local time to GMT time */ DEBUG(printf("Converting from local time to GMT time\n");); |