pike.git / lib / modules / Calendar.pmod / mkexpert.pike

version» Context lines:

pike.git/lib/modules/Calendar.pmod/mkexpert.pike:108:    return res;   }      mapping|array|string generate_expert_tree(array(object) zones)   {    if (sizeof(zones) == 1) {    // A single zone.    return zones[0]->zoneid;    }    // FIXME: Do we need to also incorporate summer-time transitions? -  // FIXME: Move the probes to the middle between transitions for -  // improved robustness against differing versions of tzdata. +     array(int) times = Array.uniq(sort(zones->shifts * ({}))); -  times = ({ times[0]-1 }) + times; +  +  // Add sentinels one year before and one year after the endpoints. +  times = ({ times[0]-31557600 }) + times + ({ times[-1] + 31557600 }); +  +  // Move the probes to between the transitions for improved robustness. +  // Updates to the tables have been known to move around transitions. +  foreach(times; int i; int t) { +  if (!i) continue; +  times[i-1] = (times[i-1] + t)/2; +  } +  times = times[..sizeof(times)-2]; +     int l, h = sizeof(times);    int start;    while (l+1 < h) {    int m = (l + h)/2;    if (times[m] < 0) l = m+1;    else h = m;    }    start = l;       // First try splitting at dates post 1970-01-01.