I read the source of time.c in samba-2.0.7 and I have some confusions
Concerning function TimeZoneFaster(time_t t) .
In my opinion, I think the purpose of this function is to create a static index
table for timezone difference. I entered some testing value and found the
function of the following code was to create a boundedly convergent range which
indicated if input time(adjusted) is during this range, zone value in this table
item indicates the time differece. The boundedly convergent range indicates the
time range for using or not using DST(I think). But I don't know where the
algorithm came from for the following code? Could anyone tell me where I can
find the regulatin and explanation for this algorithm?
BTW, during my testing process,I found that the boundedly convergent range did
not begin at midnight for the DST or non-DST range. :-( How does it happen?
/* no entry will cover more than 6 months */
low = t - MAX_DST_WIDTH/2;
if (t < low)
low = TIME_T_MIN;
high = t + MAX_DST_WIDTH/2;
if (high < t)
high = TIME_T_MAX;
/* widen the new entry using two bisection searches */
while (low+60*60 < dst_table[i].start) {
if (dst_table[i].start - low > MAX_DST_SKIP*2)
t = dst_table[i].start - MAX_DST_SKIP;
else
t = low + (dst_table[i].start-low)/2;
if (TimeZone(t) == zone)
dst_table[i].start = t;
else
low = t;
}
while (high-60*60 > dst_table[i].end) {
if (high - dst_table[i].end > MAX_DST_SKIP*2)
t = dst_table[i].end + MAX_DST_SKIP;
else
t = high - (high-dst_table[i].end)/2;
if (TimeZone(t) == zone)
dst_table[i].end = t;
else
high = t;
}
Any kind of help is greatly appreciated!
thanks,
Dustin
______________________________________
==================================================================ÐÂÀËÃâ·Ñµç×ÓÓÊÏä
http://mail.sina.com.cn
ÄãÑ¡ÊÖ»úÎÒÂòµ¥£¡(http://mall.sina.com.cn/yesmobile/)